SQL GROUP BY clause in SQL is used to arrange the same data into groups with the help of some functions. The GROUP BY clause group rows that have the same values into summary rows, like “find the number of customers in each city.” The Group By statement allows you to arrange the rows of a  query in the groups. The groups are determined by the table columns that you specify in a GROUP BY clause.

SQL Group By Example

GROUP BY in SQL is also used with the aggregate functions ( COUNT, MAX, MIN, SUM, AVG) to group the result by one or more columns. Its main work is to summarize the data from the database.

If you want to build some kind of chart then the GROUP BY clause will be helpful to fetch the summarize the data and then draw the chart based on the fetched data.

The queries that contain the GROUP BY clause are called grouped queries and only return a single row for every grouped item.

#sql #sql group by #group by

SQL Group By Example | Group By Clause In SQL
1.75 GEEK