Re: Top 20 records in a table ??

From: <trumpet999_at_my-deja.com>
Date: Thu, 13 Jan 2000 13:25:16 GMT
Message-ID: <85kjng$sm7$1_at_nnrp1.deja.com>


[Quoted] Nobody has suggested using a cursor yet. How about the following. Go easy on me I"m new to pl/sql.

Mike

  • begin of source

declare
  cursor cursor1 is
    select id, name, pay

       from emp order by pay desc;

 v_record1 type cursor1%type;
 v_counter number := 0;

begin
  open cursor1;

  loop

     fetch cursor1 into v_record1;

      ... process data ....

     v_counter := v_counter + 1;
     exit when cursor1%notfound or v_counter = 20;
   end loop;

end;

---end of source

In article <1ca4f2e8.4b527e23_at_usw-ex0102-016.remarq.com>,   agichen <agiNOagSPAM_at_feib.com.tw.invalid> wrote:
> Hello,
> How to select the highest 20 records from a table via sql*plus ??
> For example,
> emp table
> ----------------
> id number(5),
> name varchar2(20),
> pay number(8)
>
> how to select the highest 20 pay from emp ??
>
> Any idea ??
> Rgds,
> Agi
>
> * Sent from RemarQ http://www.remarq.com The Internet's Discussion
Network *
> The fastest and easiest way to search and participate in Usenet -
Free!
>
>

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Thu Jan 13 2000 - 14:25:16 CET

Original text of this message