Presumably you realise i mean 0, but have a reason for thinking null is more
appropriate? More precisely in my mind it ought to be 0 in the type of the
expression being summed.

It makes sense from a 'business' perspective. The combined weight of 0 items
would be 0.

It would be consistent with the arithmetic in expressions, where adding null
results in a null. Consider you have two tables of similar things, apples
and oranges, but wanted to know the combined weight. At one moment there are
no oranges.

sum(apples) = x
sum(oranges) = null/0

sum(apples) + sum(oranges) = null/x

blah blah ... something induction and base cases ... blah

On Tue, Feb 3, 2009 at 11:12 PM, Thomas Kellerer <
[email protected]> wrote:

>
> On 2 Feb., 19:36, Mike Goodwin <[email protected]> wrote:
> > It surprised me that the sum over 0 rows comes to null and not zero.
>
> So what is the sum of "nothing"?
>
> DROP TABLE IF EXISTS x;
> CREATE TABLE x (val INTEGER);
> INSERT INTO x values (null);
> SELECT sum(val) FROM x;
>
> also returns null.
>
>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to