SQL for Data Analysts

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

10 projects, 250 hands-on levels, run in your browser.

Syllabus

  • 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.
  • Join: Combining rows from two tables on a matching column; inner keeps matches, left keeps all left rows.
  • Normalization: Organizing tables to remove redundancy so each fact lives in one place, reducing update anomalies.
  • Primary key: A column (or set) that uniquely identifies each row in a table; no duplicates, no nulls.
  • Set operations: Combining query results as sets: UNION (combine, dedupe), INTERSECT (common rows), EXCEPT (difference).
  • Window function: A computation over rows related to the current row (running totals, rankings) that keeps every row, unlike GROUP BY.