ORDER BY and LIMIT

Sort the result and take only the first rows; together they build pages of results.

Also called: LIMIT, OFFSET, pagination

Source
General
Language
SQL

Example

ORDER BY created_at DESC LIMIT 10 shows the ten newest leads.

In code

-- page 3, 20 per page
SELECT * FROM listings ORDER BY created_at DESC LIMIT 20 OFFSET 40;

Large OFFSETs get slow; for huge lists use "keyset" pagination (WHERE id < last_seen_id).

Related terms

Added 2026-11-30 · Last reviewed 2026-11-30