Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Top-N records.

RE: Top-N records.

From: Sachin Puri <sachin_at_siworldwide.com>
Date: Sat, 13 Jan 2001 21:46:27 +0530
Message-Id: <10741.126632@fatcity.com>


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



Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
-- 
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).
Received on Sat Jan 13 2001 - 10:16:27 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US