Home » SQL & PL/SQL » SQL & PL/SQL » how to select nth maximum in a table
how to select nth maximum in a table [message #232593] Sat, 21 April 2007 14:51 Go to next message
narsi1226
Messages: 4
Registered: April 2007
Junior Member

hai to all,
i want to select Nth maximum salary of an employees table (i mean if two persons having Nth maximum salary , i want to display the name of two persons
Re: how to select nth maximum in a table [message #232596 is a reply to message #232593] Sat, 21 April 2007 15:08 Go to previous messageGo to next message
Michel Cadot
Messages: 68728
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Have a look at dense_rank function.

Regards
Michel
Re: how to select nth maximum in a table [message #232608 is a reply to message #232596] Sun, 22 April 2007 03:52 Go to previous messageGo to next message
ammishra
Messages: 179
Registered: January 2007
Location: india
Senior Member
try this

select d.last_name,d.salary from (select salary,last_name,dense_rank() over(order by salary desc) rd from employee ) d where d.rd=4



--Yash
Re: how to select nth maximum in a table [message #232613 is a reply to message #232608] Sun, 22 April 2007 07:20 Go to previous messageGo to next message
Michel Cadot
Messages: 68728
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
And what do you add to my previous answer?
Just to show us that you can read the documentation?
Well, you're a good boy.

Regards
Michel
Re: how to select nth maximum in a table [message #232618 is a reply to message #232608] Sun, 22 April 2007 11:04 Go to previous messageGo to next message
narsi1226
Messages: 4
Registered: April 2007
Junior Member

thanks for sending reply to my question
Re: how to select nth maximum in a table [message #232619 is a reply to message #232618] Sun, 22 April 2007 11:08 Go to previous message
Michel Cadot
Messages: 68728
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
You should not thank someone that gives you a solution instead of teaching how to find it by yourself.
It turns you to a slave.

Regards
Michel
Previous Topic: Hi Guys Please help me in removing this bug...
Next Topic: Check these!
Goto Forum:
  


Current Time: Sat Dec 14 12:37:46 CST 2024