Skip to content
Reference notes from the interactive SQL course, which covers the same ground with a live SQL console, graded challenges and a final exam.
Getting Started

Why SQL Matters

Three real-world scenarios where SQL is the answer — and what the alternative looks like.

Why SQL Matters

Theory is boring. Here are three real industry scenarios where SQL pays for itself in the first hour.

Scenario 1 — Monthly financial report

You work at a fintech startup. Your CFO needs total revenue per month, by product line, for the last 12 months. The raw data is in a transactions table with 8 million rows.

Without SQL: export to Excel → 8M rows breaks Excel → write a Python script → 45 minutes of glue code.

With SQL — 4 lines:

SELECT
  DATE_TRUNC('month', created_at) AS month,
  product_line,
  SUM(amount) AS revenue
FROM transactions
WHERE created_at >= NOW() - INTERVAL '12 months'
GROUP BY month, product_line
ORDER BY month, product_line;

Done. Under 5 seconds on a properly indexed table.

Scenario 2 — E-commerce search

A user types "blue running shoes under $100" into your store. You need products that match.

SELECT id, name, price, image_url
FROM products
WHERE category = 'running shoes'
  AND color = 'blue'
  AND price < 100
  AND stock > 0
ORDER BY popularity_score DESC
LIMIT 24;

Same query pattern powers every faceted search on every e-commerce site you've ever used.

Scenario 3 — User analytics dashboard

Your product manager wants the answer to "how many active users did we have last week, broken down by signup month?"

SELECT
  DATE_TRUNC('month', u.created_at) AS signup_cohort,
  COUNT(DISTINCT s.user_id) AS active_users
FROM users u
JOIN sessions s ON s.user_id = u.id
WHERE s.started_at >= NOW() - INTERVAL '7 days'
GROUP BY signup_cohort
ORDER BY signup_cohort DESC;

This is a cohort retention query. Every product analytics tool — Mixpanel, Amplitude, PostHog — runs SQL like this under the hood.

The pattern you're seeing

In every example: complex business question → 5-15 lines of SQL → answer.

The alternative is always one of:

  • A 200-line Python script
  • An Excel file that breaks at 1M+ rows
  • A "let me get back to you in 2 weeks" answer to your boss

SQL is the cheapest, fastest, most portable way to answer questions about data. That's why it's outlasted every "SQL killer" since 1995.

What's next

In the next lesson, What is an RDBMS?, we'll unpack what's actually happening under the hood when you run a SQL query — the structure that makes all of this possible.

All 43 lessons in SQL — The Interactive Visual Notebook
  1. Introduction to SQL
  2. Why SQL Matters
  3. What is an RDBMS?
  4. Tables, Rows, and Columns
  5. SQL Command Categories (DDL/DML/DCL/DQL)
  6. SELECT and FROM
  7. Aliases and Expressions
  8. DISTINCT and Sorting
  9. Limiting Results
  10. Query Execution Order
  11. WHERE and Comparison Operators
  12. Combining Conditions — AND, OR, NOT
  13. IN, BETWEEN, and LIKE
  14. Working with NULL
  15. Aggregate Functions
  16. GROUP BY
  17. HAVING — Filtering Groups
  18. Grouping in Practice
  19. INNER JOIN
  20. LEFT JOIN and Outer Joins
  21. Self Joins
  22. Cross Joins and Join Pitfalls
  23. UNION, INTERSECT, and EXCEPT
  24. Subqueries
  25. EXISTS and Correlated Subqueries
  26. Common Table Expressions (WITH)
  27. Recursive CTEs
  28. Window Functions — The OVER Clause
  29. Ranking Functions
  30. Frames and Running Totals
  31. LAG and LEAD
  32. Window Function Patterns
  33. What an Index Is
  34. Reading a Query Plan
  35. Designing Indexes
  36. Writing Queries an Index Can Use
  37. Transactions and ACID
  38. Isolation Levels
  39. Locks and Deadlocks
  40. Choosing Data Types
  41. Constraints and Keys
  42. Normalisation
  43. Designing a Schema