Accepted answer, create new variable rank and set rank equal to n


  • 0
    C

    CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
    BEGIN
    RETURN (

    Write your MySQL query statement below.

      select Salary from 
      (select distinct Salary, (select count(distinct Salary) from Employee where Salary >= e.Salary) Rank
      from Employee e) e1
      where e1.Rank=n
    

    );
    END


Log in to reply
 

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