SQL SELECT TOP Clause
The SELECT TOP statement retrieves a limited number of records from a table. It helps fetch only the required data from large datasets, improving query performance. Note that not all databases support TOP ÔÇö Oracle uses ROWNUM and MySQL uses LIMIT.
Complete Python Course with Advance topics:-
SQL Tutorial:-
Syntax of the TOP Clause
SELECT TOP number | PERCENT column1, column2
FROM table_name
WHERE [condition];
Example 1: Retrieving Top 3 Rows
SELECT TOP 3 Car_Name, Car_Color FROM Cars;
Example 2: TOP with All Columns
SELECT TOP 4 * FROM Student;
Example 3: TOP with a WHERE Filter
SELECT TOP 2 * FROM Employee WHERE Emp_City = 'Mumbai';
Example 4: TOP PERCENT
SELECT TOP 50 PERCENT * FROM Bikes;
Equivalents in Other Databases
-- MySQL
SELECT * FROM Cars LIMIT 3;
-- Oracle
SELECT * FROM Cars WHERE ROWNUM <= 3;
Download New Real Time Projects:- Click here
Complete Advance AI topics:-
Conclusion
The SELECT TOP clause efficiently retrieves a specific number of records. SQL Server uses TOP, while MySQL uses LIMIT and Oracle uses ROWNUM. Understanding these makes database queries more optimized. For more SQL tutorials, stay tuned to .
select top 10 records in sql server
select first 10 rows sql oracle
select top 10 records in mysql
sql top vs limit
sql limit
sql select top
select top rows oracle
sql select top w3schools