GROUP BY
Aggregate rows by a column
AggregationSQL
SELECT department, COUNT(*) as count, AVG(salary) as avg_salary FROM employees GROUP BY department;
What each clause does
GROUP BY groups rows by department. COUNT(*) counts rows per group. AVG(salary) computes the average salary per department.