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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Sorting in a select - help!

Re: Sorting in a select - help!

From: Gary M. Greenberg <garyg_at_southeast.net>
Date: 1997/03/12
Message-ID: <garyg-ya02408000R1203972219330001@news.southeast.net>#1/1

nils_at_bourbon.propertymall.com (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?

AFAIK, you have to sort <order by> whole columns, e.g.: order by size, amount, so on
or
order by size, so on, date
or
order by so on, date, size

So, if size, date, and so on are constants or evaluated results for a query, then you could, of course, write an if statement to determine which columns to sort on:

if (size = 0) then

    order by size, date, so on;
elsif (size > 0) then

    order by date, so on, size;
else

    order by so on, date, size;
end if;

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

order by DESC

I think,

gary         -=- visit The C Programmers' Reference -=-
          http://users.southeast.net/~garyg/C_ref/C/c.html
               The AVENUE Programmers' Class Requests
             http://users.southeast.net/~garyg/class.htm
Received on Wed Mar 12 1997 - 00:00:00 CST

Original text of this message

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