I had to work out how to do custom queries against the new Flow Storage Database. I wrote up what I learned here Extracting Netflow 4.0 data.
It's probably not exactly what you are looking for, but it will give you some hints. The SWQL Studio in the Orion SDK Orion SDK Information can be very helpful, and so can the Database Manager that is installed on your Orion server Start -> All Programs -> Solarwinds Orion -> Advanced Features -> Database Manager can help too.
Good Luck !