Re: [Q] Daves's top 10 SQL question
From: Eric Amick <eamick_at_clark.net>
Date: 1996/08/18
Message-ID: <4v7eea$99_at_clarknet.clark.net>#1/1
Date: 1996/08/18
Message-ID: <4v7eea$99_at_clarknet.clark.net>#1/1
John Griffiths (jgriffiths_at_dial.pipex.com) wrote:
>Paul Young wrote:
>> But seriously, how can you code a SQL query to first order records
>> greatest to least then pick out only a pre-selected number of them
>> without prior knowledge of their distribution. This strikes me as
>> a common, even simple thing to do, but I can't see how to do it, and
>> I've written some pretty twisted queries.
>
>SELECT
> NAME
> ,SCORE
>FROM
> StupidPetTricks
>WHERE
> ROWNUM < 11
>ORDER BY
> SCORE DESC;
Did you actually try this? Rownums are assigned *before* the data is
sorted, so all you did was sort the first 10 rows selected from the table.
-- Eric Amick eamick_at_clark.net Columbia, MD Public key available via fingerReceived on Sun Aug 18 1996 - 00:00:00 CEST