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: order by (asc and desc)

Re: order by (asc and desc)

From: Alexander I. Doroshko <aid_at_grant.kharkov.ua>
Date: 6 Nov 1999 09:08:51 GMT
Message-ID: <01bf2837$3f4593e0$190114c1@sister.grant.UUCP>


Eric Luu <ericluu_at_hotmail.com> wrote in article <382202b9$0$206_at_nntp1.ba.best.com>...
: Is there a way of choosing which ordering to use
: (ascend or descend) depending on a flag.
:
: like:
:
: select a
: from abc
: order by a decode(flag, 1, asc, 2, des)
Assuming column a is a numerical one:

order by a*decode(flag, 1, 1, -1).

If a is a char one, assuming for simplicity that in contains only alphanumerical in uppercase:

def source_ = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' def destin_ = 'ZYXWVUTSRQPONMLKJIHGFEDCBA9876543210'

order by translate(a, '&&source_', decode(flag, 1, '&&source', '&&destin')).

For date column tri

order by to_char(a, 'J') *decode(flag, 1, 1, -1).

--
 Alexander I.Doroshko, aid_at_grant.kharkov.ua

Received on Sat Nov 06 1999 - 03:08:51 CST

Original text of this message

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