Enumerable is not the only way people might implement aggregate functions. Some 
others are (a) rolling up partial aggregates, (b) pushing the process down to 
another engine, perhaps SQL, perhaps another language such as MongoDB, (c) 
computing rolling sum, by adding to a total as rows enter a window and 
subtracting from a total as rows leave.

SUM0 simplifies the specification of SUM and makes it easier to implement in a 
variety of engines. It takes NULL values out of the equation.

I concede that the expansion sometimes makes things awkward.  For instance, if 
we’re pushing down to another SQL engine, we’d rather push SUM than SUM0.

Could we defer the expansion of “SUM" to "CASE … SUM0 …” until we know whether 
we prefer the SUM form? I don’t know. It’s worth considering.

Julian

Reply via email to