Skip to main content
dbSyntax
Home CoursePracticeReferenceModelingInterview Prep
Start Here
  • What is a database?
  • What is SQL?
  • SQL syntax
  • SQL datatypes
  • How to run queries (tooling)
  • How to read tables/ERDs
SQL Foundations
  • SELECT / FROM
  • ORDER BY
  • LIMIT / OFFSET
  • DISTINCT
  • Aliases
Filtering
  • WHERE
  • AND / OR / NOT
  • IN / BETWEEN
  • LIKE
  • NULL (IS NULL, COALESCE)
Aggregation
  • COUNT / SUM / AVG / MIN / MAX
  • GROUP BY
  • HAVING
  • CASE & Conditional Aggregation
Joins
  • Joins Intro
  • INNER JOIN
  • LEFT JOIN
  • RIGHT JOIN
  • FULL OUTER JOIN
  • CROSS JOIN
  • Self Join
  • Join Debugging: Duplicates & Missing Rows
  • UNION vs UNION ALL
Subqueries & CTEs
  • Subqueries (IN / EXISTS)
  • Correlated Subqueries
  • WITH (CTEs)
Window Functions
  • OVER / PARTITION BY / ORDER BY
  • ROW_NUMBER / RANK / DENSE_RANK
  • LAG / LEAD
  • Moving Averages & Running Totals
  • QUALIFY
Data Cleaning
  • String Cleanup
  • Date Parsing
  • Deduping
Analytics Patterns
  • Top-N Per Group
  • Cohorts & Retention
  • Funnels
  • Rolling Metrics & Period-over-Period
Performance Modeling
  • Index Intuition
  • Normal Forms
  • Reading Explain Plans
Capstone
  • Capstone Part 1: KPI Baseline
  • Capstone Part 2: Cohorts & Retention
  • Capstone Part 3: Segments & Recommendation
Home / Course / Aggregation

Aggregation

Learn SQL aggregation with practical examples and guided drills on dbSyntax.

Start with COUNT / SUM / AVG / MIN / MAX

COUNT / SUM / AVG / MIN / MAX

Beginner

Aggregate functions collapse many rows into a single number. "How many orders?" "What's the total revenue?" "What's the average basket size?...

GROUP BY

Beginner

An aggregate without GROUP BY collapses the whole table into one row. GROUP BY splits the table into buckets first, then runs the aggregate ...

HAVING

Beginner

WHERE filters rows before aggregation. HAVING filters groups after aggregation. That is the entire distinction, and also why HAVING exists a...

CASE & Conditional Aggregation

Beginner

CASE is SQL's if/else. It's an expression, not a statement. It produces one value per row, so it can go anywhere a column can: in SELECT, in...

dbSyntax Write and Run SQL in Your Browser
CoursePracticeReferenceModelingInterview PrepPrivacyTerms
© 2026 dbSyntax.