My simple solution

  • 0

    select (select distinct Salary from Employee order by salary desc limit 1,1) as Salary;

  • 0

    wa, so cool, then maybe I write the complex solution

    select case when n=2 then Salary else null end SecondHighestSalary from (select n, Salary from (select case when @count:=@count+1 then @count else @count+1 end n , Salary from (select distinct Salary from Employee)e, (select @count:=0)r order by Salary desc limit 2) t1 order by n desc limit 1) t2

  • -1

    seems limit is supported only by mysql

Log in to reply

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