Re: [Q] Daves's top 10 SQL question

From: Chris Fischer <cfischer_at_nando.net>
Date: 1996/03/18
Message-ID: <4ikm1c$2l9_at_castle.nando.net>#1/1


youngpa_at_statcan.ca (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.

Unfortunately, Oracle 7 doesn't have a LIMIT TO clause such as Rdb has. The closest match is WHERE ROWNUM <= 10. But this is not at all reliable because the ROWNUM clause may be evaluated and parsed during the select phase, before the rows are sorted. Sorry.

+------------------------------------------------------------+
| Chris Fischer                           cfischer_at_nando.net |
| Sr. Systems Analyst                    Work: (919)676-0062 |
| Toys "R" Us                                                |
+------------------------------------------------------------+
Received on Mon Mar 18 1996 - 00:00:00 CET

Original text of this message