Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Top-N records.
Sachin,
This is only partially right depending on your interpretation of the question. If the top salary is 100,000 dollars and 50 people have that salary - your answer will bring back all 50 people - thats not top 20
Sorry matey, I'm not too impressed with your answer also
Sam Roberts
-----Original Message-----
From: Sachin Puri [mailto:sachin_at_siworldwide.com]
Sent: Monday, January 15, 2001 8:00 AM
To: Multiple recipients of list ORACLE-L
Subject: 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-----
Sent: Saturday, January 13, 2001 2:54 AM
To: Multiple recipients of list ORACLE-L
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-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).
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Sachin Puri
INET: sachin_at_siworldwide.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-L (or the name of mailing list you want to be removed from). You may Received on Sun Jan 14 2001 - 23:46:20 CST
![]() |
![]() |