W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > October to December 2009

Re: Semantics of SUM

From: Andy Seaborne <andy.seaborne@talis.com>
Date: Sat, 14 Nov 2009 22:01:52 +0000
Message-ID: <4AFF28D0.7060001@talis.com>
To: Steve Harris <steve.harris@garlik.com>
CC: RDF Data Access Working Group <public-rdf-dawg@w3.org>

On 14/11/2009 06:05, Steve Harris wrote:
> On 13 Nov 2009, at 17:05, Andy Seaborne wrote:
>> Summary :
>> SQL standard requires nulls to be skipped in SUM.
>> MySQL skips errors just like NULLs.
>> PostgreSQL skips nulls and expression errors on sum(val+5)
>> PostgreSQL causes an error on casting error.
>> Addition with + and nulls does not work as sum over nulls.
> The last point I'm not sure sure that it's possible to tell is it? As
> SUM skips NULLs, how do you tell the difference?

The SQL standard says that aggregates can see the nulls and then choose 
what to do.  Sum() does not include it in the summation so it isn't as 
simple as sum is "+" over the group.  All the standard aggregates do this.


1+null ==> null

But sum() over 1,null ==> 1

To me, this means that the description of sum delegating to "+" isn't 
accurate as it's made some decisions on the way.  The semantics of sum 
are more than just those of "+" applied across the group.


> - Steve
Received on Saturday, 14 November 2009 22:02:07 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:00:57 UTC