SQL SELECT TOP Keyword
The SELECT TOP command is used in SQL Server to return only the top N rows in a result set.
Note:
- SQL Server uses
SELECT TOP
- MySQL and SQLite use
LIMIT
- Oracle uses
ROWNUM
SQL SELECT TOP Syntax
SQL
x
1
SELECT TOP number column1, column2, ...
2
FROM table_name;
SQL SELECT TOP Example
SQL
1
1
SELECT TOP 3 *
2
FROM Patients;
Note: This code does not work in TechKubo playground. SQLite does not support
SELECT TOP
. UseLIMIT
instead.
SQL SELECT TOP Equivalent Using LIMIT Example
SQL
1
1
SELECT *
2
FROM Patients
3
LIMIT 3;

SQL SELECT TOP Equivalent Using ROWNUM (Oracle Only)
SQL
1
1
SELECT *
2
FROM Patients
3
WHERE ROWNUM <= 3;
Note: This code does not work in TechKubo playground. SQLite does not support
ROWNUM
.