How do you group data by a single field?
To group data by a single field, use the GROUP BY operator with that field's name.
Example
sql
SELECT department, COUNT(*)
FROM employees
GROUP BY department;Here:
GROUP BY departmentcreates groups by department name,COUNT(*)counts employees in each department.
In the result, each output row is one group sharing a common department value plus its computed aggregate.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.