TechnoLearnAcademy

SQL GROUP BY Statement

THE SQL GROUP BY Statement is used to group rows that have the same values in specified columns into summary rows.
We can apply aggregate functions like SUM, COUNT, AVG, MAX, or MIN to calculate values for each group.
GROUP BY WITH WHERE
Let’s understand the group by statement with an example. For demonstration purposes, we will be using the table emp.
         Table Emp

Example:

   Objective: In this example, we will find the sum of salary for the IT department only.
                     SELECT Department , SUM(Salary) as [TotalSalary] FROM Tbl_Emp
                                                        WHERE Department = ‘IT’
                                                        GROUP BY Department;
    Output:
Scroll to Top