Suggest an editImprove this articleRefine the answer for “What does GROUP BY do?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)`GROUP BY` **groups rows** that share the same values in the specified columns, so you can apply **aggregate functions** (`COUNT`, `SUM`, `AVG`, and so on) to each group separately. **Key point:** without `GROUP BY`, aggregate functions run over the whole table; with it, they run **on each group of values** separately.Shown above the full answer for quick recall.Answer (EN)Image`GROUP BY` **groups rows** that share the same values in the specified columns, so you can apply **aggregate functions** (`COUNT`, `SUM`, `AVG`, and so on) to each group separately. ### Example ```sql SELECT department, AVG(salary) FROM employees GROUP BY department; ``` The data gets grouped by `department`, and the **average salary** is computed for each department. Without `GROUP BY`, aggregate functions run over the whole table; with it, they run **on each group of values**.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.