Find max and second max salary for a employee table MySQL

Simplest way to fetch second max salary & nth salary
"select 
 DISTINCT(salary) 
from employee 
 order by salary desc 
limit 1,1"
Note:
limit 0,1  - Top max salary
limit 1,1  - Second max salary
limit 2,1  - Third max salary
limit 3,1  - Fourth max salary

0 Comments

Post a Comment

Post a Comment (0)

Previous Post Next Post