Second Highest Salary In SQL

 SELECT MAX(salary) AS second_highest_salary

FROM employees

WHERE salary < (

  SELECT MAX(salary)

  FROM employees

);



select salary AS second_highest_salary  from emp order by desc limit 1,1


SELECT salary FROM (SELECT salary, ROW_NUMBER() OVER(ORDER BY salary DESC) as rank FROM `emp` ) emp where rank = 2;


SELECT salary FROM (SELECT salary, DENSE_RANK() OVER(ORDER BY salary DESC) as rank FROM `emp` ) emp where rank = 2;


Comments

Popular posts from this blog

Add Css And Js Files on Specific Page In laravel

Xpendy Pending

Laravel Join with two coloums