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.

Why SQL Matters — SQL Mastery — From Zero to Joins