Reputation: 148664
Ive read here about it ( use it rarely)
but I have a problem understanding something :
this is the datasource :
according to this query :
SELECT Country,[State],City,
SUM ([Population (in Millions)]) AS [Population (in Millions)]
FROM tblPopulation
GROUP BY Country,[State],City WITH ROLLUP
if im grouping by : Country, State, City
so every row is distinct ! ( because of the city)
so after every
row - there should be a "middle sum "
but there isn't.
what am I missing ?
p.s. the result is :
Upvotes: 2
Views: 329
Reputation: 171216
The last column never gets a "middle sum" even if it is not distinct. Lets say all your cities were either "A" or "B". You wouldn't want a "middle sum" per city because you already have it! You have the sums for "A" and "B" already. Also, you couldn't distinguish the "middle sums" for "A" and "B" because they were both set to null. The two rows would be identical (with different counts).
Upvotes: 1