Re: SQL Question
From: martijn <mlinsen_at_vx8000.nl>
Date: 2000/07/17
Message-ID: <39731708.0_at_gaspra.oss.akzonobel.nl>#1/1
begin
open c_test;
while x<=10 loop /* top ten */ fetch c_test into r_test;
dbms_output.put_line(r_test.count||' '||r_test.id); /* show the values on screen */
Date: 2000/07/17
Message-ID: <39731708.0_at_gaspra.oss.akzonobel.nl>#1/1
The order by will not work until Oracle 8, so until then you will have to use PL/SQL:
declare
cursor c_test
is
select count,id from table_name order by count desc; x number:=1; r_test c_test%rowtype;
begin
open c_test;
while x<=10 loop /* top ten */ fetch c_test into r_test;
dbms_output.put_line(r_test.count||' '||r_test.id); /* show the values on screen */
x:=x+1;
end loop;
close c_test;
end;
If you only want to use SQL, you will have to use subqueries (in your case
9) which
will be a lot more typing (If anyone has a better idea, i'd like to know
too!!).
heyzz wrote in message <8kr1qh$2j22$1_at_news.cz.js.cn>...
>oh, sorry, I make a mistake. that is for sql server. and it is for oracle:
>
>select * from (
> select * from table_name order by count desc )
>where rownum <=10;
>
>
>
Received on Mon Jul 17 2000 - 00:00:00 CEST