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

Home -> Community -> Usenet -> c.d.o.server -> Re: How to get "...WHERE test IN (5,23,2,12,56)" in this order

Re: How to get "...WHERE test IN (5,23,2,12,56)" in this order

From: Dirk Huber <maiwert_at_t-online.de>
Date: Fri, 18 Jan 2002 13:39:17 +0100
Message-ID: <a294up$5bi$02$1@news.t-online.com>


Thomas,

this one is genius!
Thank you very much!

Greetings, Dirk

....

> SQL> select *
> 2 from t
> 3 order by instr( ',' || '5,23,2,12,56' || ',', ',' || x || ',' );
>
> X
> ----------
> 5
> 23
> 2
> 12
> 56
>
>
> See, the second query is orderd by the list you supply. Now, if the that
list
> can contain whitespace and such, you'll want to use REPLACE() on it to
remove
> the whitespace so the numbers are all:
>
> ,NUMBER,NUMBER,NUMBER,
....

> >> Thomas Kyte (tkyte@us.oracle.com) http://asktom.oracle.com/
> >> Expert one on one Oracle, programming techniques and solutions for
Oracle.
> >> http://www.amazon.com/exec/obidos/ASIN/1861004826/
> >> Opinions are mine and do not necessarily reflect those of Oracle Corp
> >>
Received on Fri Jan 18 2002 - 06:39:17 CST

Original text of this message

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