Published on August 12, 2024By DeveloperBreeze

SQL: How to Select Top N Records

-- For SQL Server
SELECT TOP 10 * FROM Customers;

-- For MySQL and PostgreSQL
SELECT * FROM Customers LIMIT 10;

-- For Oracle
SELECT * FROM (SELECT * FROM Customers) WHERE ROWNUM <= 10;

Comments

Please log in to leave a comment.

Continue Reading: