Bored Analyst
SQL

Practice Problem Index

Work these to cement the patterns. Ordered by concept, not difficulty.

Aggregation and GROUP BY

  • Count records by status with percent of total
  • Multi-metric summary per group with HAVING threshold
  • Conditional aggregation with CASE

JOINs

  • Multi-table enrichment joins
  • Anti-join: LEFT JOIN ... IS NULL vs NOT EXISTS
  • Self-join pair problems

Subqueries

  • Scalar subquery comparisons against group averages
  • EXISTS for multi-condition membership
  • IN and NOT IN filtering cases

CTEs

  • Waterfall funnel with counts at each step
  • Compute -> classify -> summarize pipelines
  • Recursive hierarchy traversal with depth/path

Window Functions

  • Latest record per group (ROW_NUMBER)
  • Top N per group (DENSE_RANK or ROW_NUMBER)
  • Running totals
  • Month-over-month change with LAG
  • Bucketing with NTILE
  • Percent of total and cumulative percent

Interview Classics

  • Find duplicates
  • Nth highest salary
  • Consecutive day streaks
  • Pivot rows to columns
  • Period-over-period growth
  • Cohort retention

On this page