Lesson 7 of 22 · SQLite

Sorting & Limiting

Sort results with SQL ORDER BY (ASC and DESC) and take the top rows with LIMIT and OFFSET.

Sorting Results

SELECT * FROM table ORDER BY column ASC;   -- Ascending (default)
SELECT * FROM table ORDER BY column DESC;  -- Descending

Limiting Results

SELECT * FROM table LIMIT 10;         -- First 10 rows
SELECT * FROM table LIMIT 10 OFFSET 5; -- Skip 5, then 10

Your challenge

Show the 3 most recent crime reports, newest first.

Solve it in your browser

Free, no sign-up. The SQLite database runs in your browser; your answer is checked instantly, with hints if you need them.