SQL TUTORIALS-
SQL GROUP BY Statement
Introduction-
β How to use the SQL GROUP BY statement with examples. Master grouping, aggregate functions (SUM, COUNT, AVG), and advanced GROUP BY techniques
β In a Simple Word The GROUP BY statement in SQL is used to arrange (same) identical data into groups.used with (collection) aggregate functions like COUNT(), SUM(), AVG(), MAX(), or MIN() to perform (working) operations on each group....
SQL GROUP BY must be used with columns that are not aggregated.This is useful for reporting, analytics, and data summarization.
β Syntax Example -
SELECT column_name, AGGREGATE_FUNCTION(column_name)
FROM table_name
GROUP BY column_name;
SQL GROUP BY Operator. Example of Table 1)-Employee
| EmpID | Name | Department | Salary |
|---|---|---|---|
| 1 | ANNI | HR | 25000 |
| 2 | BOULT | IT | 50000 |
| 3 | POOJA | IT | 60000 |
| 4 | SUNNY | SALES | 65000 |