ROWNUM

SQL ROWNUM Keyword

The ROWNUM keyword is used in Oracle databases to limit the number of rows returned by a query. It allows you to filter and return a specific number of rows from a result set.

Note:

  • SQL Server uses SELECT TOP
  • MySQL and SQLite use LIMIT
  • Oracle uses ROWNUM

Tutorials dojo strip

SQL ROWNUM Syntax

SELECT column_names
FROM table_name
WHERE ROWNUM <= number;

SQL ROWNUM Example

This query selects the first 3 rows from the Patients table.

SELECT *
FROM Patients
WHERE ROWNUM <= 3;

Note: This code does not work in the TechKubo playground. SQLite (and TechKubo) does not support ROWNUM. To achieve the same result in SQLite, use LIMIT instead.

SQL LIMIT Equivalent Example

SELECT *
FROM Patients
LIMIT 3;

SQL ROWNUM Labs

Tutorials dojo strip
Scroll to Top