my solution with limit, offset.


  • 0
    C

    '''
    CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
    BEGIN
    set N=N-1;
    RETURN (
    # Write your MySQL query statement below.
    select( select distinct Salary from Employee order by Salary Desc limit 1 offset N )as nthHightestSalary

    );
    END
    '''


  • 0

    Wondering why you use 2 levels of Select:
    select( select distinct Salary from Employee order by Salary Desc limit 1 offset N )as nthHightestSalary

    Instead of simply using 1 level:

    select distinct Salary AS nthHightestSalary from Employee order by Salary Desc limit 1 offset N


Log in to reply
 

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