Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Top-N records.
Aldi
I just saw this topic today. I also saw comments of various dbas regarding
your query but was
not impressed by anyone.
You can successfully use this query and i bet this will not give you any
problems:
select salary from employee x where 20 >
(select count(*) from employee y where y.salary > x.salary) order by
x.salary desc;
However if the u want to have top 20 distinct salaries then add distinct clause.
Sachin Puri
Oracle Development and Administration
Solutions Infosystems
-----Original Message-----
From: Aldi Barco [mailto:ipal_at_hotmail.com]
Sent: Saturday, January 13, 2001 2:54 AM
To: Multiple recipients of list ORACLE-L
Subject: Top-N records.
Hi List,
This question has been discussed so many times.
But I dont have the trick now.
Could you please send me the trick to select top-20
salary of scott.employee table ?
Thanks.
Aldi
-- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Aldi Barco INET: ipal_at_hotmail.com 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-LReceived on Sat Jan 13 2001 - 10:16:27 CST
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).
![]() |
![]() |