Top N with LIMIT and OFFSET

Top N selects the first N rows of a ranking: you sort with ORDER BY, then limit with LIMIT. OFFSET skips a number of rows, which enables pagination. Without a deterministic sort, for example with a second unique criterion, results may vary in case of ties.

Example

SELECT * FROM produits ORDER BY prix DESC LIMIT 5 OFFSET 10;

Related concepts

The whole glossary