I am curious why you used Views to build SQL and then not use Views?
When it comes to more complex things, such as many or many relationships, GROUP BY, COUNT, SUM, subqueries, etc., whatever the function requires, it's best to write it yourself (especially if the Contrib modules do not have view support, and you need more than a node table).
For me, when the views cannot be executed, I write a simple module that calls hook_menu (to register the paths) with a callback that executes the queries I need.
Kevin
source share