Group By


Group by clause is used to group a selected set of rows into a set of summary rows by the values of one or more columns or expression are called Group By. Group By always used in conjunction with one or more aggregate functions.

Aggregate Functions : (AVG, COUNT, MAX, MIN, SUM).

Syntax :-

SELECT column_name(s)

FROM table_name

GROUP BY column_name(s);

Example : Let's see how to used Group by clause in table. we have one table and table name is customers. If you want to see the total amount of the salary on each customer, then the GROUP BY query would be as follows.

Query :

SELECT Name, MIN(Salary)

FROM customers

GROUP BY  Name;

Output :

Now, you can see customer salary is Group By.