On 9/8/05, D. Richard Hipp <[EMAIL PROTECTED]> wrote: > > > So then, if there are no input rows at all (if no rows > match the WHERE clause) then SUM returns 0. (This makes > sense because if you say: > > SELECT sum(amt) FROM sales WHERE month='october'; > > and you didn't sell anything in October, you want an > answer of 0, not NULL.) Or if *some* of the entries are > NULL, then the answer is the sum of the non-NULL entries. > But if the number of entries is greater than zero and > they are all NULL, then the answer is NULL. > > Logical, right????
A sum is the addition of a set of numbers. Your logic is correct if you make an assumption that there's always a zero to start with. Then the sum of an empty set is: zero + (nothing) = zero. An empty set can't have a binary operation applied to it. You could also argue "The Since there are no numbers, there is no sum." Isn't this specified in cj date's SQL standards book someplace?