Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Simple Query of multiple record

Re: Simple Query of multiple record

From: Steve Cosner <stevec_at_zimmer.csufresno.edu>
Date: 1997/03/14
Message-ID: <5ganm3$ld@info.csufresno.edu>#1/1

In article <33273FF8.F08_at_idt.net>, Joseph Jao <jjao_at_idt.net> wrote:
>Hi, I tried to make a simple SQL command query to get the names of 3 top
>paid persons. "Select name, sal from emp where rownum<4 order by sal
>desc;" doesn't work. "Select name, sal from emp order by sal desc;"
>works but it'll bring everything. Can anyone help me?

Rownum doesn't work--it is assigned before the sort is done (I think).

You have to use an explicit cursor:
Declare
 n1 emp.name%type; n2 emp.name%type; n3 amp.name%type;  s1 emp.sal%type; s2 emp.sal%type; s3 emp.sal%type;  cursor c is select name,sal from emp order by sal desc; Begin
  open c;
  fetch c into n1,s1; fetch c into n2,s2; fetch c into n2,s3;   close c;
End; Received on Fri Mar 14 1997 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US