> 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

   You (and I) may want an answer of 0, but I unfortunately believe NULL
is the correct answer.  The answer isn't 0 - the answer is "there is no
answer", because there were no inputs.  If that translates to 0 in
reality that's up to you to interpret. :)

   I think the set-theoretical explanation is that an operation on a
NULL set is NULL.  COUNT seems to be an exception there, though...
Hrmph.


> The more I learn about NULLs in SQL the less sense they
> make...

   I have never intentionally declared a column that allowed NULLs. :)

   -Tom

Reply via email to