Why is "SELECT DISTINCT Salary FROM Employee ORDER BY Salary DESC LIMIT N-1, 1" wrong?


  • 0
    S

    Why is "SELECT DISTINCT Salary FROM Employee ORDER BY Salary DESC LIMIT N-1, 1" wrong?


  • 6
    J

    You should add SET N = N -1 before the return.

    Check out mysql function syntax :-)


  • 0
    A

    According to MySQL reference manual, LIMIT parameters can only be specified by

    (1) nonnegative integer constants,
    (2) placeholder ? in prepared statement,
    (3) integer-valued routine parameters or local variables in stored program.

    So expression N-1 is not allowed here.


Log in to reply
 

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