SQL From Zero to Hero in 30 Days — Day 5 Expanding the Group by

Soner Yıldırım
4 min readNov 11, 2021

Learn, practice, master.

(image by author)

The links below will be updated as we progress into the series:

Welcome to day 5 of this series!

In the previous article, we went over how to use the group by statement to calculate some aggregated values for distinct values in a column or multiple columns.

This article will expand the previous article by using some other SQL functions that make SQL an efficient exploratory data analysis tool.

We will be using the following sales table for the examples in this article:

SELECT TOP 5 * FROM sales

In the previous article, we calculated the average price of products for each product group. Let’s start by making a quick recap with one example.

SELECT ProductGroup, AVG(ProductPrice)
FROM sales
GROUP BY ProductGroup

--

--