Thursday, April 24, 2008

find the Nth max sal in employee table.

Here is the query to find the Nth max salary of an employee:

SELECT distinct(salary) from employee order by salary desc limit(n-1,1);

like for 3rd highest salary query will be:

SELECT distict (salary) from employee order by salary desc limit(2,1);

No comments:

 
Custom Search