warming up your workspace

SQL for Data Analysts

Learn SQL by answering real analytics questions: query, filter, aggregate, join, and uncover insights in a live database.

11 projects, 275 hands-on levels, run in your browser.

Syllabus

  • Foundations: data through SQL: Never queried a database before? Start here. You will learn to read tables, filter and sort rows, summarize with aggregates, and join tables, all through a small shop dataset. By the end you are ready for Project 1.
  • Querying Data: The analyst's foundation: pull exactly the rows and columns you need. Select and filter, sort and limit, aggregate, and group, all against a live customers/orders/products database.
  • Joins: Real questions span tables. Combine customers, orders, and products with INNER and LEFT joins, join three tables at once, and aggregate across the joined result to answer questions no single table can.
  • Subqueries and CTEs: Answer questions that need a query inside a query: compare rows to an aggregate, filter by another query's results with IN and EXISTS, and structure multi-step analysis cleanly with common table expressions (WITH).
  • Window Functions: Compute across rows without collapsing them. Rank rows, build running totals, compare each row to its group or its neighbors, the tools behind leaderboards, cumulative charts, and period-over-period analysis.
  • Data Cleaning: Real data is messy: missing values, inconsistent casing, stray whitespace, text dates. Use CASE, NULL handling, string functions, and date functions to turn a raw signups table into clean, analyzable data.
  • Funnels and Cohorts: The analyst's signature work: measure how users flow through a funnel (visit, signup, activate, purchase), compute stage-to-stage conversion, and group users into signup cohorts to compare their behavior.
  • Set Operations: Combine and compare whole result sets. UNION stacks rows, INTERSECT keeps the common ones, EXCEPT subtracts, and UNION ALL builds multi-section reports with subtotal and total rows.
  • Time-Series Analysis: Track metrics over time. Build a monthly revenue series, compute running totals and moving averages with window frames, and measure month-over-month growth, the core of every trend dashboard.
  • Advanced Patterns: The analyst's bag of tricks: self-joins to compare rows within a table, NTILE and percent ranks for bucketing, first/last-per-group with window ordering, and deduplication of dirty imports.
  • Capstone Analytics Project: The finale: a complete analytics project. Profile customers, analyze products, chart revenue trends, segment the base, and assemble an executive summary, applying every technique from the track to one real database.

Key concepts

  • Aggregation: Reducing many rows to summary values (count, sum, average), usually per group via GROUP BY.
  • Cohort analysis: Grouping users by a shared start (e.g., signup month) and tracking each group over time to compare retention.
  • Common table expression: A named temporary result (WITH ...) that breaks a complex query into readable, composable steps.
  • Foreign key: A column that references another table's primary key, encoding a relationship between rows.
  • Funnel analysis: Measuring how many users pass each step of a sequence (e.g., view -> add-to-cart -> buy) to find where they drop off.
  • GROUP BY: The SQL clause that groups rows so aggregate functions can summarize each group. For example, grouping orders by customer lets COUNT(*) or SUM(total) produce o…
  • Join: Combining rows from two tables on a matching column; inner keeps matches, left keeps all left rows.
  • Join cardinality: The row-multiplication behavior caused by a join: one-to-one, one-to-many, many-to-one, or many-to-many. Misreading cardinality is a common reason counts and r…
  • LEFT JOIN: A join that keeps every row from the left table and fills missing right-side matches with nulls. It is essential for retention, missing activity, and denominat…
  • Normalization: Organizing tables to remove redundancy so each fact lives in one place, reducing update anomalies.
  • Null handling: The practice of accounting for unknown or missing values in SQL. COALESCE , IS NULL , and careful join logic prevent nulls from silently breaking filters, arit…
  • Percentile: A position-based summary showing the value below which a percentage of rows fall. Percentiles are useful for latency, spend, or usage distributions where avera…
  • Primary key: A column (or set) that uniquely identifies each row in a table; no duplicates, no nulls.
  • Retention: The share of users from a cohort who return or stay active after a period of time. Retention queries usually combine cohorts, date offsets, left joins, and gro…
  • Set operations: Combining query results as sets: UNION (combine, dedupe), INTERSECT (common rows), EXCEPT (difference).
  • Subquery: A query nested inside another query. Subqueries can filter against derived results, compute scalar values, or stage intermediate tables when a CTE is not neces…
  • Window frame: The subset of rows inside a partition that a window function can see for the current row. Frames define behavior such as running totals, moving averages, and p…
  • Window function: A computation over rows related to the current row (running totals, rankings) that keeps every row, unlike GROUP BY.
  • Window partition: The PARTITION BY part of a window function that resets the calculation for each group. A running total partitioned by customer starts over for every customer w…