3 ms·
Because 0 is a valid sum for non empty sets, so it’s nice to be able to differentiate between: the items add up to 0 and: there are no items to sum.
by christophilus 6y ago
Because 0 is a valid sum for non empty sets, so it’s nice to be able to differentiate between: the items add up to 0 and: there are no items to sum.
- petters 6y agoIt is useful to have the sum and product of empty lists be 0 and 1, respectively. This means that sum(A ++ B) = sum(A) + sum(B). (++ is concatenation)
- magicalhippo 6y agoAnd you can have that by using COALESCE(SUM(A), 0) for example.
- heavenlyblue 6y agoBut COUNT is just a SUM over ones for every row in the output
- tsimionescu 6y agoBy what definition? If anything, sums are defined as cardinalities of sets, rather than defining cardinalities in terms of sums.
- heavenlyblue 6y agoThen what is a NULL cardinality?