Suggest an editImprove this articleRefine the answer for “How do you group data by multiple fields?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)To group data by multiple fields, list **several columns separated by commas** in `GROUP BY`, e.g. `GROUP BY department, position` - SQL groups by department first, then by position within each department. **Key point:** the result is **every unique combination** of values from the listed fields, e.g. "Sales + Manager" and "Sales + Assistant" become separate groups.Shown above the full answer for quick recall.Answer (EN)ImageTo group data by multiple fields, list **several columns separated by commas** in `GROUP BY`. ### Example ```sql SELECT department, position, COUNT(*) FROM employees GROUP BY department, position; ``` Here: - SQL groups by `department` first, - then, within each department, by `position`. The result ends up looking like, for example: - Department "Sales" + Position "Manager" -> 5 people - Department "Sales" + Position "Assistant" -> 3 people So the result is **every unique combination** of values from the listed fields.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.