Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Sorting in a select - help!
Nils wrote:
>
> I wish to make a select and have the data sorted, i.e.
>
> select * from DTABLE
> where
> (
> QTOWN = DTABLE.TOWN
> )
> order by size_000_s ;
>
> Questions: (to which, having consulted a couple of books,
> I cannot find a solution)
>
> (1) There are 3 different columns by which I could sort, i.e. size, date and so on - how can I do this - essentially I qould like to pass a parameter QSORT and then sort by size if it is 0, date if it is 1 and so on?
>
This would require the use of Dynamic SQL, or to define three cursors,
and choosing which cursor to process based on the value of an input
flag.
> (2) How can I reverse a sort - instead of the reault being sorted lowest to highest numeric value, I would like it sorted highest to lowest.
>
> Thanks,
>
> Nils
Nils:
Sorts in Oracle SQL are by default ascending sorts. If you wish to change the order you would enter the query as shown below:
select * from DTABLE where ( QTOWN = DTABLE.TOWN ) order by size_000_s DESC;
Hope this helps,
John Hough Received on Wed Mar 12 1997 - 00:00:00 CST
![]() |
![]() |