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

From: David Pais <davidp3_at_soho.ios.com>
Date: 1996/03/30
Message-ID: <4jii66$vk_002_at_davidp3.ios.com>#1/1


In article <4j6uh1$l7s_at_news.Belgium.EU.net>, ghp_at_infosoft.be (Gerard H. Pille) wrote:
>In article <NEWTNews.827736760.23046.elric_dm_at_dialup.netvision.net.il>,
>Yoram zilberberg (elric_dm_at_netvision.net.il) says...
>!>
>!>
>!>here is a possible answer:
>!>select <column>[,<column>]
>!>from table[,table]
>!>where rownum < 11
>!>order by <order_columns>
>!>
>!>so you see, oracle will retreive all the rows (order by does that)
>!>but you will get just the first ten.
>!>note that you can still use group by etc.
>!>
>!>how-ever, the real thing can be to define a cursor from that select
>!>and tehn fetching just the first 10 (in Pro*C it will be just
>!>one fetch, in Pl/Sql you'll have to work a bit harder)
>!>
>!>good luck
>!>
>!>
>
>I'm afraid you're wrong, Yoram. It will fetch the first ten rows and
>order those.
>--
>Kind reGards
> \ / |
> X |
> / \ s
> Gerard
>
Lets make it clear
query like shown above written in SQL will retrieve first N records from table and sort THEM, so, it is no good at all

But if PL*SQL used, let say:
cursor c1 is select my_any_column
from my_table
order by sort_rule;
and then fetch first N record out of active set-well, it will do the job quite nicely
Dave Received on Sat Mar 30 1996 - 00:00:00 CET

Original text of this message