Write a SQL query to fetch top n records?

Discussion RoomCategory: Database&SQLWrite a SQL query to fetch top n records?
Nick asked 6 years ago

In mySQL using LIMIT-
SELECT * FROM EmployeeSalary ORDER BY Salary DESC LIMIT N
In SQL server using TOP command-
SELECT TOP N * FROM EmployeeSalary ORDER BY Salary DESC
In Oracle using ROWNUM-
SELECT * FROM (SELECT * FROM EmployeeSalary ORDER BY Salary DESC)
WHERE ROWNUM <= 3;

Scroll to Top