SQL Exercises

Advanced SQL GROUP BY Exercises

0 Exercises
~0 min

Advanced-level SQL GROUP BY practice exercises with solutions.

Exercise 1

Question: Find total revenue by product category and month.

SELECT product_category, DATE_TRUNC('month', order_date) AS month, SUM(amount) AS total_revenue FROM orders GROUP BY product_category, DATE_TRUNC('month', order_date) ORDER BY month, total_revenue DESC;

Group by multiple columns for multi-dimensional analysis. DATE_TRUNC normalizes dates to month boundaries.

Related Content

From Our Blog

Ready for more practice?

Join SQL Mastery and get access to interactive exercises, quizzes, and more.