Skip to Main Content

SQL & PL/SQL

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!

Oracle 10g group by sorting

641320Jul 27 2009 — edited Jul 27 2009
Hello friends

Pls refere to my previous thread where we have discussed on sorting oprtion of Adding order by whereever group by is applicable
3624069


Read?

Then come to my point


if there is multiple columns for the group by then if we want to include order by clause, same number of columns has to be included in the order by also.

i dont think it is so

example'


SELECT SUM(QTY1),SUM(QTY2), PARTNO, PART_DESC
from part_sen
group by partno, part_desc
order by partno, part_desc

qty1 qty2 partno partdesc
70 101 I001 BRAKE SHOE
56 54 I002 HORN
30 30 I003 GEAR
15 5 I004 DOOR
5 5 I007 MOTOR GEAR
10 15 I008 ANCILLARY
10 15 I009 Window


so in order by clause we can include only the first column.. that is partno

SELECT SUM(QTY1),SUM(QTY2), PARTNO, PART_DESC
from part_sen
group by partno, part_desc
order by partno

Same result i get.


Pls give your suggestion

s
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 24 2009
Added on Jul 27 2009
9 comments
1,085 views