SQL in 30 days. One topic at a time.
Weeks 1-2: SELECT, WHERE, GROUP BY. Week 3: JOINs and CTEs. Week 4: window functions, then interview mode.
One hour a day. 20 minutes learning, 30 minutes solving, 10 minutes redoing what you got wrong.
Don't jump between courses. Pick one and finish it.
Save this and start Day 1 tonight.
Weeks 1-2: the basics
Read data
- SELECT, WHERE, ORDER BY, LIMIT
- AND / OR, IN, BETWEEN, LIKE
- IS NULL and COALESCE
- 20 easy problems
Summarise
- COUNT, SUM, AVG, MIN, MAX
- GROUP BY + HAVING
- CASE WHEN for buckets
- 25 problems
Week 3: combine tables
JOINs
- INNER, LEFT and self joins
- Rows with no match: LEFT JOIN + IS NULL
- UNION vs UNION ALL
Subqueries + CTEs
- Subquery inside WHERE
- WITH ... AS (CTE)
- Split one hard question into 2-3 steps
Week 4: what interviews test
Window functions
- ROW_NUMBER, RANK, DENSE_RANK
- LAG / LEAD for change vs last month
- Running total with SUM() OVER
Interview mode
- 2 medium problems a day, 20 min each
- Explain every query out loud
- 1 project on a real sales dataset
The query you'll write again and again
top_3_per_category.sql
WITH ranked AS (
SELECT category, product, sales,
DENSE_RANK() OVER (
PARTITION BY category
ORDER BY sales DESC) AS rnk
FROM product_sales
)
SELECT category, product, sales
FROM ranked
WHERE rnk <= 3;Top N per group. Once you can write this without notes, week 4 is done.
Your daily hour
| Block | Time | Do |
|---|---|---|
| Learn | 20 min | One concept |
| Practise | 30 min | 3-5 problems |
| Review | 10 min | Redo one wrong answer |
Practice gets the most time. Reading is not learning.
Rules for 30 days
Don't
- Jump between 5 courses
- Copy the solution
- Wait for a free weekend
Do
- One resource, start to end
- Type every query yourself
- 1 hour, every single day