# Lesson 3: Sorting and LIMIT We look at sorting and LIMIT the way working developers use it, with examples you can change and run straight away. Full lesson: [https://glibcode.net/courses/sql-essentials/lessons/3](https://glibcode.net/courses/sql-essentials/lessons/3) ## Files - `sorting.sql`: ORDER BY and LIMIT for top-N lists > **Tip:** Write the FROM and JOIN lines first, then SELECT: it matches how the database reads the query. > **Tip:** Count before you delete: run the same WHERE with `SELECT COUNT(*)` first. ## Run it ```sh sqlite3 shop.db < ../../setup/schema.sql sqlite3 shop.db < ../../setup/seed.sql sqlite3 shop.db < sorting.sql ``` ## Exercises See [exercises.md](exercises.md). Ask in the forum once you've tried.