On 9/8/05, D. Richard Hipp <[EMAIL PROTECTED]> wrote: > > Can somebody come up with a realistic scenario where they would > actually want SUM() to return NULL instead of 0? NULL is such > a profoundly broken return value for sum() in my mind that I'm > thinking of ignoring the standard and just coding SQLite to do > the Right Thing. But I am open to the possibility that there > are some cases outside of my imagination where returning zero > might be considered "wrong". > > If nobody can suggest a scenario where SUM() returning NULL is > actually helpful, then I will likely return SQLite to its former > mode of operation which is to have SUM() return 0 when it has no > input.
Look at NULL as an error message. When you ask it to do a binary operation (sum is addition) on an empty set it can't since it doesn't have two values, so it returns an error indication. It's probably a lot more practically useful to return zero, but it's not standard.