SQL is small. The core fits in a few dozen keywords, so the keywords are not what takes time. The slow part is judgment, which means knowing when a result looks wrong. To build it, this plan assumes 45 to 60 minutes a day and a free database such as PostgreSQL or SQLite. If you can only spare 30 minutes, the plan still works, but it will take about six weeks instead of four.
The 30-day plan
| Week | Study | You can now answer |
|---|---|---|
| 1 | SELECT, WHERE, ORDER BY, LIMIT, COUNT, SUM, AVG | How many orders did we get last month, and what was the average value? |
| 2 | GROUP BY, HAVING, INNER and LEFT JOIN | Revenue by region, and which customers never ordered? |
| 3 | Subqueries, CTEs, CASE, window functions | Top 3 products per category, and month-over-month growth? |
| 4 | One project on a real dataset | A question you chose, answered with a query and a short explanation |
Week 1: read the data before you shape it
We start with the simplest job, which is reading rows. To pick the rows, we use WHERE. To summarise them, we use COUNT, SUM and AVG. Before every query, write one line, "I expect about N rows". When the result disagrees, you have found something worth understanding. A shop owner does the same when she counts the cash drawer against the till receipts before she closes.
Week 2: joins are where results go wrong
Now that we can read one table, we combine two. Learn INNER JOIN and LEFT JOIN together, and always compare the row count before and after. Most wrong dashboards trace back to a join that multiplied rows.
SELECT COUNT(*) FROM orders; -- 1,000
SELECT COUNT(*) FROM orders o
JOIN order_items i ON i.order_id = o.order_id; -- more than 1,000? find out whyWeek 3: write it clearly, then write it fast
A long query is hard to read, because the reader has to hold every step in mind. To name each step, we use CTEs, so another person can follow the query. Window functions come next, once joins feel natural. We also learn how NULL behaves now, since it starts to cause trouble as soon as subqueries appear.
WITH monthly AS (
SELECT date_trunc('month', order_date) AS month, SUM(total_amount) AS revenue
FROM orders GROUP BY 1
)
SELECT month, revenue,
revenue / LAG(revenue) OVER (ORDER BY month) - 1 AS growth
FROM monthly;Week 4: finish one project
Pick a dataset, write one business question, answer it in SQL and explain the number in three sentences. A short project with an explained answer shows more than twenty solved exercises, because it shows how you chose the question and checked the result.
How to practise so it sticks
- Type every query yourself, since copying an answer teaches almost nothing.
- Predict the result first, then run it.
- Re-run a solved problem a week later without looking at the answer.
- Keep a short list of mistakes, such as a join that multiplied rows or a
NULLinsideNOT IN.


