Mark As Completed Discussion

Grouping in SQL

Introduction

The SELECT statement's optional clause - GROUP BY, is used to group one or multiple rows with the same values into summary rows. This statement may be applied in a variety of scenarios, for example, when we want to find the number of employees in each department. The GROUP BY is an aggregate function and is frequently used in conjunction with other aggregate functions to group the result set by one or more columns, including COUNT(), MAX(), MIN(), SUM(), and AVG(). In the end, if the data was aggregated, this grouping method will return one; otherwise, it will return zero.

In this tutorial, we will go through a couple of examples that will help us get a better understanding of how the GROUP BY statement actually works and how it can be useful in real-world scenarios. The two tables with which we will be working in this tutorial are called Table1 and Table2 which can be seen below.

Introduction