Re: Top 20 records in a table ??

From: Vincent Wittlin <vincent.wittlin_at_libertysurf.fr>
Date: Tue, 11 Jan 2000 17:44:17 +0100
Message-ID: <85fmc8$6ig$1_at_jaydee.iway.fr>


If you want only 20 lines, you have to type this :

Select /*+ index_desc (emp i_pay) */ pay from emp where pay >0
And Rownum<21

you want all people in the top 20 salary positions type this :

Select id,name,pay from emp where pay
in (Select /*+ index_desc (emp i_pay) */ pay from emp where pay >0
And Rownum<21);

In both cases , you must have created index i_pay on the emp table.

With This solution, you will read only the needed data.

agichen <agiNOagSPAM_at_feib.com.tw.invalid> a écrit dans le message : 1ca4f2e8.4b527e23_at_usw-ex0102-016.remarq.com...
> 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!
>
Received on Tue Jan 11 2000 - 17:44:17 CET

Original text of this message