Sorting & Limiting3 / 10
Up next

Cap rows with LIMIT

CREATE TABLE score (id INTEGER, name TEXT, points INTEGER);
INSERT INTO score VALUES (1, 'A', 30), (2, 'B', 90), (3, 'C', 60);
-- LIMIT applies after ORDER BY
SELECT name, points
FROM score
ORDER BY points DESC
LIMIT 2;
What you're solving

LIMIT after sorting