Re: Finding the 10 smallest values in a column

From: Tim Hall <tim.hall_at_spam.begone>
Date: 1997/11/13
Message-ID: <346ac5ef.278054_at_69.0.9.9>#1/1


On 12 Nov 1997 23:37:05 GMT, JF_Brown_at_pnl.gov (Jeff Brown) wrote:

>How about (I didn't test this, but I've used similar):
>
>Select VAL
> From TABLE
> Where ROWNUM < 11
> Order by VAL Asc
>;
>
>If you want values only once, make that "Select Distinct VAL".
>

[Quoted] Oh No, not again!

[Quoted] [Quoted] Querying by ROWNUM with an order by D*O*E*S N*O*T W*O*R*K!!!

It will select the first 10 rows it finds, and then sort them. To select the 10 smallest values, put the query in a cursor and only fetch the first 10 rows. This is the only way to do it that's guaranteed to work!



Tim Hall, Indus International (was TSW International)

http://www.tswi.com
http://www.indusgroup.com

Replace domain name with the domain from the first URL before replying via email! Received on Thu Nov 13 1997 - 00:00:00 CET

Original text of this message