Home » SQL & PL/SQL » SQL & PL/SQL » How to get Second Highest Salary in employee table (Oracle 8i.Window-XP)
How to get Second Highest Salary in employee table [message #384758] Thu, 05 February 2009 01:14 Go to next message
Jothish
Messages: 22
Registered: February 2009
Location: Chennai
Junior Member
How to get Second Highest Salary in employee table
1)Without Using ROWID AND ROWNUM
2)With Using ROWID AND ROWNUM

for Eg: Consider There are 5 records In employee table
6000
3000
5000
2000
1000

EXPECTED OUTPUT--> Should be 5000 (How to get this Second Highest Salary)

Re: How to get Second Highest Salary in employee table [message #384759 is a reply to message #384758] Thu, 05 February 2009 01:21 Go to previous messageGo to next message
trivendra
Messages: 208
Registered: October 2007
Location: Noida, India
Senior Member
Hi,

I hope this is you homework and without try for any thing you just posted your question. Look for Rank () , dense_rank() functions.
Re: How to get Second Highest Salary in employee table [message #384826 is a reply to message #384758] Thu, 05 February 2009 06:29 Go to previous message
cookiemonster
Messages: 12403
Registered: September 2008
Location: Rainy Manchester
Senior Member
For 2 - you only need to use rownum, rowid is never necessary for this type of query.
Previous Topic: Primary key and unique+not null
Next Topic: How do I combine data from multiple rows into a single row?
Goto Forum:
  


Current Time: Sun Dec 04 12:23:51 CST 2016

Total time taken to generate the page: 0.08817 seconds