Grokking SQL for Tech Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
LIMIT and OFFSET
On this page

LIMIT

Example

OFFSET

Example

LIMIT

The LIMIT clause restricts the number of rows a query returns. It is specified as LIMIT [number], where [number] is the maximum number of rows to be returned.

Example

Suppose you want to retrieve only the first 10 rows from a table; you would use LIMIT 10.

SELECT * FROM your_table LIMIT 10;

OFFSET

The OFFSET clause is used to skip a specific number of rows before returning the rows. It is specified as OFFSET [number], where [number] is the number of rows to skip.

It is commonly used with LIMIT to implement pagination or retrieve a subset of rows.

Example

Suppose you want to retrieve 10 rows, starting from the 11th row (skipping the first 10 rows).

SELECT * FROM your_table LIMIT 10 OFFSET 10;

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page

LIMIT

Example

OFFSET

Example