Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> simple SQL query question
Hi,
Ok I have this simple query..
SELECT id, name
FROM people
where id in (176, 181, 22, 61);
which returns..
id name
---------------------------------------------------------------------
22 John 61 Sam 176 Tom 181 Pam
What I want is for the query to return the "names" and "ids" in the
order of the in() clause.
Since my in() clause looks like this, in (176, 181, 22, 61). I want my
results to look like this..
id name
---------------------------------------------------------------------
176 Tom 181 Pam 22 John 61 Sam
As you can see they are in the order of the IN() clause, (176, 181, 22, 61). I am not to sure on how I could do this, one of my friends told me to use decode, so i have been messing around with that all day today. Any help or ideas will be appreciated.
Thanks,
-Jimmie
Received on Wed Dec 07 2005 - 12:52:00 CST