469,329 Members | 1,428 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,329 developers. It's quick & easy.

group by works, order by gives error msg

Hi

I am a student, I am trying to figure this out. I am trying to run a select statement that is asking for customer#, date, and total price of each order. ensure results are in chronological order based upon order date.

When I run the following with just a group by clause, it works. If I add order by orderdate, I get an error message that states SQL Error: ORA-00979: not a GROUP BY expression. Why is the order by clause giving me a group by error message, but the group by works fine? How else would I get the results in chronological order?
Dec 1 '08 #1
3 3666
Pilgrim333
127 100+
Hi,

Could you post both of the queries you have tried?

Pilgrim.
Dec 1 '08 #2
Thanks for getting back to me, I can't believe I forgot to add the code! lol

what I am looking to do:
list customer#, date, and total price of each order. ensure results are in chronological order based upon order date

the following select statement with just a group by (which works) :

select customer#, order#, sum(quantity*retail) "total order"
from orders join orderitems using (order#)
join books using (isbn)
group by customer#, order#;

If I add order by orderdate; after the group by statement, I get this msg:

Error starting at line 5 in command:
select customer#, order#, sum(quantity*retail) "total order"
from orders join orderitems using (order#)
join books using (isbn)
group by customer#, order#
order by orderdate;
Error at Command Line:9 Column:9
Error report:
SQL Error: ORA-00979: not a GROUP BY expression
00979. 00000 - "not a GROUP BY expression"
*Cause:
*Action:

Should I be specifying orderdate in the select statement? (orderdate is in the orderitems table)
Dec 1 '08 #3
Pilgrim333
127 100+
Hi,

Indeed, you should specify the orderdate in de select statement and the group by statement.

Pilgrim.
Dec 3 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Randell D. | last post: by
11 posts views Thread by Experienced but Undocumented | last post: by
2 posts views Thread by Experienced but Undocumented | last post: by
5 posts views Thread by Seb | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Purva khokhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.