create a ranking variable but 2/14 test cases did not pass. not sure why? can someone help?


  • 0
    C
    CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
    BEGIN
    
      RETURN (
          # Write your MySQL query statement below.
          Select distinct salary from
    (Select salary,
                @rank:= if (@presal=Salary, @rank, @rank+1) as Rank,
                @presal:=Salary
    From employee, (select @rank:=0, @presal=-1) init
    Order by salary desc) tmp
    Where Rank=N
    
      );
    END
    

Log in to reply
 

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