Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Query Builder - sort order causing ORA-00979 error

712342Jul 16 2009 — edited Jul 22 2009
Hello,
I'm having an issue with the "sort order" clause in the query builder tool when using a function on the same column.

I've build a simple query in the gui and the following statement is displayed in the SQL Window
select "DEMO_ORDER_ITEMS"."ORDER_ID" as "ORDER_ID",
sum(DEMO_ORDER_ITEMS.QUANTITY) as "QUANTITY"
from "DEMO_ORDER_ITEMS" "DEMO_ORDER_ITEMS"
group by DEMO_ORDER_ITEMS.ORDER_ID

and if I add a sort order of "1" on the quantity field, the following query is changed to
select "DEMO_ORDER_ITEMS"."ORDER_ID" as "ORDER_ID",
sum(DEMO_ORDER_ITEMS.QUANTITY) as "QUANTITY"
from "DEMO_ORDER_ITEMS" "DEMO_ORDER_ITEMS"
group by DEMO_ORDER_ITEMS.ORDER_ID
order by DEMO_ORDER_ITEMS.QUANTITY DESC

When running this query I get an error
failed to parse SQL query:
ORA-00979: not a GROUP BY expression

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.

I've tried to do some searching and haven't found much documentation on this issue. Any assistance is appreciated.

Thanks,
Tony
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 19 2009
Added on Jul 16 2009
4 comments
1,006 views