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: Eric Luu <ericluu_at_hotmail.com>
Date: Tue, 9 Nov 1999 16:21:44 -0800
Message-ID: <3828ba3e$0$232@nntp1.ba.best.com>


Thanks but I came up with a solution.

select a
  from abc
 order by decode(flag, 0, null, a) asc,

              decode(flag, 1, null, a) desc

Alexander I. Doroshko wrote in message
<01bf2837$3f4593e0$190114c1_at_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
> * Bank "Grant", Kharkov, Ukraine
Received on Tue Nov 09 1999 - 18:21:44 CST

Original text of this message

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