I'd need to use a premier support ticket to help you write the proper SQL query. I'd have to play with it and try different queries to get it right and I don't have an easy way to do that here without direct access to your database.
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.