Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: group by sorting

Re: group by sorting

From: Rod Corderey <RodCorderey_at_Lane-Associates.com>
Date: Wed, 18 Oct 2000 14:24:24 +0100
Message-Id: <10653.119636@fatcity.com>


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.com



> "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.
>
Received on Wed Oct 18 2000 - 08:24:24 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US