Re: Q: SQL output order by keys possible?
From: Joe Nardone <nardone_at_patriot.net>
Date: 1996/10/09
Message-ID: <53eun2$gpl_at_washington.patriot.net>#1/1
Date: 1996/10/09
Message-ID: <53eun2$gpl_at_washington.patriot.net>#1/1
Göran Alterland (f91-gal_at_nada.kth.se) wrote:
: select EMP,SALAR from ALL_EMPS
: where SALAR <= 10000
: order by DEPT where DEPT like 'PR' first
:
: This doesn't work of course. Is there any way to do this? The
: best I can come up with on my own are two queries like this:
:
Well, if there are a limited (and known) number of DEPT's
that start with PR, you can use a decode:
...ORDER BY DECODE(DEPT,'PRAAA',1,'PRBBB',1,...,2) Which will "assign" a 1 to each value declared (replacing PRAAA, PRBBB, etc with the real dept. names) and a 2 to anything else.
Actually, you could make it more generic.
...ORDER BY DECODE(SUBSTR(DEPT,1,2),'PR',1,2) Joe
-- =-------------------------------------------------------------------------= Joe Nardone <nardone_at_patriot.net> "No, no, warp speed is too slow." "Too slow??" "We'll have to go right to -- ludicrous speed!"Received on Wed Oct 09 1996 - 00:00:00 CEST