SQL
SELECT TOP Clause
SELECT TOP clause is used to select the top records form a table.
Basic Syntax
SELECT column_name(s)
FROM table_name
WHERE condition
LIMIT number;
Example
Note: we can use all the three below methods for the same example.
Where we want to select top 3 customers from a customers table.
SELECT TOP 3 * FROM Customers;
It works same like the above using LIMIT Clause
SELECT * FROM Customers
LIMIT 3;
It works same like the above using ROWNUM
SELECT * FROM Customers
WHERE ROWNUM <= 3;
If we want to select top records with a specific condition or place
SELECT * FROM Customers
WHERE Country='Germany'
LIMIT 3;