This content has been marked as final. Show 4 replies
I think you need to order by
then the query should work fine
Michael, I knew that already, see my original posting
"It is quite obvious what is wrong with the query but I don't know how to get the query builder tool to generate the correct statement. The order by clause should be order by sum(DEMO_ORDER_ITEMS.QUANTITY) DESC"
The question is how to get the query builder tool to generate this order by statement?
Simple answer is, DON'T DEPEND UPON THE QUERY BUILDER TO WRITE ALL OF YOUR CODE.... Take the code it builds and tweak it.. If you depend on the code it produces, your queries will NOT be as complete as taking the output it produces and modifying it to get the BEST performance out of the selects you are doing..
While this statement is generally certainly true and should also be remembered, it is not really helpful for the specific case.1 person found this helpful
I think the behaviour described is a bug. However this might be one a little difficult to solve. The user unfortunatly can't influence much of the query builder results directly.
Either put 1 into the order by clause or use the column alias name without table alias name ("QUANTITY" only).
My personal solution would be NOT TO use any sort criteia in the query builder. This makes sense in so far as the generated SQL is often basis for some report. If that is an interactive report you won't add a sort order anyway. This is a layout thing and layout will be handled by the end user itself. he can choose whatever sorting he wants.
Edited by: Sven W. on Jul 22, 2009 11:43 AM