Re: Examples of SQL anomalies?

From: Brian Selzer <brian_at_selzer-software.com>
Date: Sat, 5 Jul 2008 00:43:17 -0400
Message-ID: <FZCbk.13095$xZ.1155_at_nlpi070.nbdc.sbc.com>


"David BL" <davidbl_at_iinet.net.au> wrote in message news:cfb587f5-ff58-48c7-ad1d-53540c7b8d7d_at_e39g2000hsf.googlegroups.com...
> On Jul 5, 8:49 am, Marshall <marshall.spi..._at_gmail.com> wrote:
>> What can be meaningfully asked is determined by the schema.
>>
>> If the schema specifies that the weight attribute is nullable,
>> then the question of how much a shipment weighs in total
>> is a question that cannot be asked.
>>
>> Marshall
>
> IMO aggregate functions are only defined on well defined sets and only
> give well defined answers. SUM should never return NULL.
> Nevertheless it is meaningful to calculate SUM on a nullable weight
> attribute. Rather than upset the mathematical simplicity of aggregate
> functions one can easily make sense of the result by correctly
> interpreting the intensional definition of the set being aggregated.
> For example in this case it is the set of *known* weights. It is
> absurd to not allow this to be calculated, by returning NULL.

It is not absurd. If you want just the *known* weights, then qualify the query with "weight IS NOT NULL." What is absurd is not returning NULL for the unqualified sum when there are *unknown* weights. Garbage in; garbage out. Isn't that the rule? If at least one of the weights is not *known*, then the input to SUM contains garbage, and so the output of SUM should also be garbage. Received on Sat Jul 05 2008 - 06:43:17 CEST

Original text of this message