SELECT FUNC(col)
FROM tableName
GROUP BY col1;
# will perform func on col in groups of col1
SELECT FUNC(col)
FROM tableName
GROUP BY col1, col2;
# will perform func on col in groups of col1 and col2
SELECT FUNC(col)
FROM tableName
GROUP BY col1
ORDER BY col1;
# NOTE ORDER BY MUST COME AFTER GROUP BY or LIMIT
SELECT col
FROM tableName
GROUP BY FUNC(col);
SELECT col1, col2
FROM tableName
GROUP BY 1;
# groups by the first column in select
Having (filter groups)
SELECT *
FROM tableName
GROUP BY col1
HAVING AVG(col) < col;
# same as where but works with functions, used to filter groups