Professional Documents
Culture Documents
Group by Aggregation Fns SQL
Group by Aggregation Fns SQL
It creates various groups with key as customer_id for each group and value is the set of all rows that have customer_id = that
cust_id, we can apply any aggregate function (like SUM, MIN, MAX, COUNT, AVG etc.) on that group and get the output
select
<selected_columns>,
agg(colD), agg(colE)
from
tbl
GROUP BY
<group_by_cols>
[MySQL doesn't throw an error even when <selected_columns> is not a subset of <group_by_cols>]
It shows the data corresponding to the first row of that column
But it's not accurate