2nd highest salary in Employee??


  • 0
    Y

    SELECT TOP 1 Salary FROM ( SELECT TOP 2 Salary FROM Employee ORDER BY Salary DESC) AS Emp ORDER BY Salary ASC

    What is wrong with my above code? Always run time error!


  • 1
    S

    You are using "TOP" to limit the number or results.
    TOP is used in SQL Server.
    The query must be in MySQL syntax. MySQL uses LIMIT instead of TOP.
    Thus, SELECT TOP 2 * FROM Table in SQL Server would be SELECT * FROM Table LIMIT 2; in MySQL


Log in to reply
 

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