What are aggregated columns and non-aggregated columns? I have read the MySQL Handling of GROUP BY
and am confused. I do not know what 'aggregated columns' mean. Does anybody know?
MySQL Handling of GROUP BY
link
Functions like SUM
, AVG
, MAX
, MIN
, COUNT
calculate data over a group of records and return aggregated results.
E.g.
SELECT SUM(`salary`) FROM `employees`;
Returns 1 row with the total salary when
SELECT `salary` FROM `employees`;
Returns multiple rows with the salary per employee.
Lets say you want the average salary per gender:
SELECT `gender`, AVG(`salary`) FROM `employees` GROUP BY `gender`;
Query 1 & 3 contain aggregated columns: SUM(`salary`)
AND AVG(`salary`)