SQL Practice
Hands-on SQL lessons - write real queries against a live in-browser database and get checked instantly.
SQL Practice
Twenty-six short, hands-on SQL lessons, from a single SELECT all the way past
joins into subqueries, window functions, transactions, many-to-many joins, CTEs,
CASE, UNION, ALTER TABLE, and self-joins. Each lesson gives you a task, a live
database, and a Run button - you write the query, run it, and get checked
instantly. Everything runs in your browser.
The last six are the ones that matter at work, where the query runs, returns a
result, and is still wrong: a single NULL that empties a NOT IN, a join that
quietly doubles your revenue, a status column everyone forgets, a typo that
splits one company into three, and two capstones where the hard part is pinning
down what the question actually means.
Start with lesson 1. You can leave and come back any time - your code is saved locally.
Lessons
26 total- 01 Select specific columns
- 02 Filter rows with WHERE
- 03 Sort and limit results
- 04 Count and summarize
- 05 Group rows together
- 06 Filter groups with HAVING
- 07 Combine tables with JOIN
- 08 Capstone: total spent per customer
- 09 Subqueries: a query inside a query
- 10 Rank rows with a window function
- 11 Messy data: NULLs and duplicate names
- 12 Transactions: all or nothing
- 13 Capstone: rank customers, gaps included
- 14 Many-to-many: joining through a junction table
- 15 CTEs: naming a subquery with WITH
- 16 CASE: bucket rows into categories
- 17 UNION: combining two result sets
- 18 ALTER TABLE: changing a table's shape
- 19 Self-join: a table joined to itself
- 20 Fix the bug: rows go missing, no error
- 21 Fix the bug: NOT IN quietly returns nothing
- 22 Fix the bug: a JOIN that doubles your revenue
- 23 The status column everyone forgets
- 24 One typo splits a group into three
- 25 Capstone: define "top customer" before you query it
- 26 Capstone: who has churned