Junior — Middle
What is the purpose and use of data grouping in database management systems?
sobes.tech AI
Answer from AI
Data grouping in database management systems (DBMS) is used to combine rows with identical values in one or more columns to perform aggregate functions (such as SUM, COUNT, AVG) on each group. This allows obtaining summary information, for example, total sales per region or the number of orders per customer.
In SQL, the GROUP BY operator is used for grouping.
Example:
SELECT department, COUNT(*) AS employee_count
FROM employees
GROUP BY department;
This query counts the number of employees in each department.