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
create a ranking variable but 2/14 test cases did not pass. not sure why? can someone help?
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.