Reputation: 35
I started learning mysql for a week and I was just trying to solve questions in LeetCode I tried writing this for the nth highest number but i keep getting a syntax error.I can't figure out. It will be great if someone could take a look.Thanks
SELECT DISTINCT Salary FROM Employee
ORDER BY Salary DESC
LIMIT N-1,1;
Upvotes: 1
Views: 39
Reputation: 562398
LIMIT
cannot accept expressions. It only accepts integers.
See https://dev.mysql.com/doc/refman/8.0/en/select.html:
LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants, with these exceptions:
Within prepared statements, LIMIT parameters can be specified using ? placeholder markers.
Within stored programs, LIMIT parameters can be specified using integer-valued routine parameters or local variables.
Upvotes: 1