Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: top n or top n%
try this.
select * from emp a
where 20 > (select count(*) from emp b
where a.sal < b.sal);
-----Original Message-----
From: root_at_fatcity.com [mailto:root_at_fatcity.com]On Behalf Of Suhen Pather
Sent: Wednesday, February 14, 2001 7:33 AM
To: Multiple recipients of list ORACLE-L
Subject: RE: top n or top n%
Leslie,
Try using a rownum.
select * from emp
where rownum<20
order by sal;
HTH
Suhen
Hi listers,
I remeber vaguely there is a way to select top n or top % rows of a select statement. But I cannot find it anywhere. Could somebody let me know? Thank you.
Leslie
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists --------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists --------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).zǞ¨}ND