Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
GROUP BY – Recap
4. Grouping by a single column
Summary

Instruction

To quickly recap what you already know about grouping rows in SQL, here is a simple problem: suppose we want to know the average score for each TV show contestant over the course of five weeks. In SQL, we'd write the following query:

SELECT
  full_name,
  AVG(score) AS avg_score
FROM contest_score
GROUP BY full_name;

In this simple query, we grouped the results by a single column (full_name) and used the AVG() function to calculate the average score for each contestant. Nothing really difficult.

Exercise

How much, in total, was spent on deliveries for each category? Show two columns: category and the sum of total_price (as total).

Stuck? Here's a hint!

Simply GROUP BY category.