Accepted Solution Second Highest Salary


  • 0
    V
    # Write your MySQL query statement below
    (SELECT Y.Salary AS SecondHighestSalary
    FROM
        (SELECT Salary 
        FROM Employee
        WHERE 1 <   (
                        SELECT Count(DISTINCT Salary)
                        FROM Employee
                    )
        ORDER BY Salary DESC
        LIMIT 2
        ) as Y
    ORDER BY Y.Salary ASC
    LIMIT 1
    )
    UNION ALL
    (
    SELECT NULL
    )
    LIMIT 1

  • 1
    B

    select max(salary) as SecondHighestSalary from employee where salary < (select max(salary) from employee)union all ( select null ) limit 1


Log in to reply
 

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