View previous topic :: View next topic
|
Author |
Message |
dilpreet
New User
Joined: 18 Mar 2008 Posts: 34 Location: INDIA
|
|
|
|
in a employee table i need to find the 6th maximum salary. what would be the query for this? |
|
Back to top |
|
|
bhairon singh rathore
New User
Joined: 19 Jun 2008 Posts: 91 Location: banglore
|
|
|
|
select max(salary) from emp_table where salary<select max(salary) from emp_table where salary <................Repeat how much you want to go back.............<select max(salary) from emp_table |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Hi
Use below query..
Code: |
SELECT col1
FROM tab1 E1
WHERE ( 6 =
( SELECT COUNT ( DISTINCT ( E2.col1 ) )
FROM tab1 E2
WHERE E2.col1 >=E1.col1));
|
|
|
Back to top |
|
|
bhairon singh rathore
New User
Joined: 19 Jun 2008 Posts: 91 Location: banglore
|
|
|
|
Hi dilpreet
Sambhaji has provided better way to implement it.
i had only seen till 2nd max salary |
|
Back to top |
|
|
|