Home » SQL & PL/SQL » SQL & PL/SQL » How do i get n'th greatest salary from EMP table
How do i get n'th greatest salary from EMP table [message #21391] Wed, 31 July 2002 21:47 Go to next message
venkatesh
Messages: 72
Registered: August 2000
Member
hi everybody

How do i get n'th greatest salary from EMP table

thanx in advance
venki
Re: How do i get n'th greatest salary from EMP table [message #21392 is a reply to message #21391] Wed, 31 July 2002 23:19 Go to previous messageGo to next message
Chandan Singh
Messages: 14
Registered: July 2002
Junior Member
Check this Query to get nth greatest salary.

select min(sal) "2nd Highest Sal" from
(select sal from
(select distinct sal from emp order by sal desc)
where rownum <= '&1');
after executing this query u will be prompted to enter the number like after entering 2 it will show u the 2 highest salary.

Emp table is the same table that ships with the oracle.

I hope this will solve your problem.
Re: How do i get n'th greatest salary from EMP table [message #21440 is a reply to message #21391] Sat, 03 August 2002 02:43 Go to previous message
Paramaguru
Messages: 4
Registered: June 2001
Junior Member
Plz try the follwing query,Without Rownum.

select a.sal from emp a where &a=(select count(distinct(b.sal)) from emp b where a.sal<=b.sal)
Previous Topic: Problem while creating SEQUENCE from PL/SQL
Next Topic: SQL query problem - help needed pls
Goto Forum:
  


Current Time: Thu Apr 25 19:32:11 CDT 2024