Reputation:
Why do I have to group all my selected columns in group by if i started to group by one column?
For instance, why can't i just have only two groups? as below:
SELECT A, B, C, D
FROM MYTB
GROUB BY A, B
Upvotes: 0
Views: 105
Reputation: 13179
You can group by as many elements as you want. Just make sure any non-grouped elements in your select have some aggregation.
SELECT A, B, SUM(C), MAX(D)
FROM MYTB
GROUP BY A, B
See
Upvotes: 1