Reputation: 47783
Is it a requirement that you have to group by something in your select if aggregating such as using SUM? That you must have a group by clause?
Upvotes: 2
Views: 82
Reputation: 453990
No it is not a requirement.
Aggregates without a GROUP BY
are Scalar aggregates and always return exactly one row.
Example
SELECT SUM(high)
FROM master..spt_values
WHERE 1 = 0
Aggregates with a GROUP BY
are Vector aggregates and return zero or one row per group.
Example
SELECT [type], SUM(high)
FROM master..spt_values
WHERE 1 = 0
GROUP BY [type]
Upvotes: 6