Re: Operator 'in' in a select statement
Date: 1996/05/28
Message-ID: <4ofu6d$las_at_ralph.vnet.net>#1/1
The the WHERE clause, and any operators used in it like "IN" , only deals with determining what rows will be included in the result set. To order the rows, use the ORDER BY clause.
SELECT col1 FROM table1 WHERE col1 IN (10,20,15,30) ORDER BY col1
will give ascending order.
10
15
20
30
SELECT col1 FROM table1 WHERE col1 IN (10,20,15,30) ORDER BY col1 d
will give descending order.
30
20
15
10
To get some arbitruary order use a calculated value in the ORDER BY
SELECT col1 FROM table1 WHERE col1 IN (10,20,15,30) ORDER BY DECODE(col1,10,1,20,2,15,3,30,4,5)
will give
10
20
15
30
Jim Wales
In article <4o6r5f$k41_at_everest.vol.it>, scomp_at_mbox.vot.it (Stefano Compieta)
wrote:
>Hi,
>
>I don't know how the operator 'IN' work retrieving columns in a select
>statement . For example in the following select :
>
> SELECT col1 FROM table1 WHERE col1 IN (10,20,15,30)
>
>columns are displayed
>
> col1
> --------
> 30
> 15
> 20
> 10
>
>order is different to the order I write in the select statement .
>How I can do if I want to retrieve columns in the order I write them ?
>
>Thanks ,
>
>
> Stefano Compieta .
>
Received on Tue May 28 1996 - 00:00:00 CEST