Skip to content
Pricing

Free SQL Course for Data Analysts: 14 Hands-on Lessons

SQL from the first GROUP BY to query plans, built from raw rows and checked against Python.

14 lessonsAbout 28 hours5 beginner, 7 intermediate, 2 advancedFree, runs offline

This phase teaches the SQL an analyst writes every day, starting from one raw table and ending with the queries interviewers use to separate juniors from seniors: grouping and totals, joins that neither drop nor double count rows, window functions, and cohort retention. Each lesson has a business problem with a named stakeholder, a small synthetic dataset, and a trap that gives a plausible wrong number, shown failing on the lesson's own data. You prove every answer twice: once in SQL, and once in a plain Python loop inside the test. Each lesson follows the course format in LESSON_TEMPLATE.md.

  1. 1. GROUP BY from raw rows

    How much did each city bring in last quarter, and which cities are big enough to matter?

    Level 1: Beginner · about 2 hours

  2. 2. Dates and the date spine

    What were signups per day, including the days with zero?

    Level 1: Beginner · about 2 hours

  3. 3. Joins without losing rows

    Which customers have never ordered, and what is revenue by city without counting any order twice?

    Level 1: Beginner · about 2 hours

  4. 4. Anti-joins, self-joins and UNION

    Which customers ordered in March but not in April?

    Level 1: Beginner · about 2 hours

  5. 5. Subqueries and CTEs

    Which customers spent more than their city's average?

    Level 1: Beginner · about 2 hours

  6. 6. Duplicates and reconciliation

    After the CRM import doubled some rows, how many unique customers really signed up?

    Level 2: Intermediate · about 2 hours

  7. 7. Window functions

    How is each region tracking against its fiscal year to date, who are the top reps, and did revenue go up or down from last month?

    Level 2: Intermediate · about 2 hours

  8. 8. Rolling averages and percent of total

    What is the 7-day moving average of orders, and each region's share of revenue?

    Level 2: Intermediate · about 2 hours

  9. 9. Sessionization from raw events

    How many sessions does each user have with a 30-minute timeout, and how long is a session?

    Level 2: Intermediate · about 2 hours

  10. 10. Gaps and islands: streaks

    Which users logged a workout three days in a row, and what is the longest streak?

    Level 2: Intermediate · about 2 hours

  11. 11. Cohort retention

    Of the users who signed up in each month, what share were still active one, two and three months later?

    Level 2: Intermediate · about 2 hours

  12. 12. Review a query someone else wrote

    A teammate, or an assistant, wrote this query. Is the number on the slide right?

    Level 2: Intermediate · about 2 hours

  13. 13. Query plans and indexes

    Why does the dashboard query take 40 seconds, and what does the query plan say?

    Level 3: Advanced · about 2 hours

  14. 14. SQL dialects for work and interviews

    How do the same five queries look in SQLite, Postgres, BigQuery and Snowflake?

    Level 3: Advanced · about 2 hours

By the end of the phase you will have built and tested each of these yourself, one per lesson:

Clone the course and run the first lesson's test. It fails until your exercise is right. You need only Python 3.9 or later.

git clone https://github.com/Ani19arya/analytics-from-scratch
cd analytics-from-scratch/phases/01-sql/01-group-by-from-raw-rows
python3 test_lesson.py
This phase on GitHub

Open roles on Real Analyst Jobs where this phase's skills come up, read daily from company career pages:

All 12 phases of Analytics from Scratch

Raj