Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: group by sorting
As others have said , you can simply add an order by after the group by.
Unless the group by is part of an inner query or inline view. In that case an order by is not allowed.
The way to overcome this is to group by the necessary columns to satisfy the group functions but then add an overriding value to your group by to which you can apply a factor of -1,
eg
presuming that invoice_no is numeric
then group by invoice_no, invoice_date
becomes group by invoice_no*-1, to_number(to_char(invoice_date,'J')) * -1
or something similar.
the effect is to reverse the sort order of the group by.
hope it helps
Rod Corderey
-- Lane Associates RodCorderey_at_Lane-Associates.com http://www.Lane-Associates.comReceived on Wed Oct 18 2000 - 08:24:24 CDT
> "Bowes, Chris" wrote:
>
> I have looked in a couple manuals for this but have not found it. When doing a
> group by, a sort is done on the data. Is there anyway to specify a descending order
> for that sort? It is defaulted to ascending. Is there a way of overriding that?
> I told the developer that she should put it into a subquery but the query itself
> (all 3 pages) is already complex enough. Any ideas? Thank you in advance.
>
![]() |
![]() |