SQL Aggregation Practice Problems: 563 Questions with Solutions

563 SQL aggregation practice problems with solutions: GROUP BY, HAVING, COUNT, SUM, AVG and COUNT DISTINCT. Written in MySQL, judged on hidden datasets.

  • Problems: 563
  • By difficulty: 134 easy · 291 medium · 138 hard
  • Dialect: MySQL

Practise SQL aggregation: GROUP BY with COUNT, SUM, AVG, MIN and MAX, HAVING to filter groups, COUNT(DISTINCT …) and grouping after a join. Every reference solution is written in MySQL and checked against a real MySQL 8. Aggregation is where most reporting questions — totals per day, the top customer, averages per department — begin.

Easy SQL aggregation problems

Medium SQL aggregation problems

Hard SQL aggregation problems

Every SQL problem · The SQL skill test