my solution using count can handle null or nth highest salary

  • 0

    SELECT MAX(SecondHighestSalary) as SecondHighestSalary FROM (
    SELECT distinct e1.Salary as SecondHighestSalary FROM employee e1 where (select count(distinct e2.salary) from employee e2 where e2.salary > e1.salary) = 1
    ) as sub

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.