Re: Meeting recap - Logic and Databases with Jeff Davis

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: "Randal L(dot) Schwartz" <merlyn(at)stonehenge(dot)com>
Cc: "David E(dot) Wheeler" <david(at)kineticode(dot)com>, PDX PostgreSQL Users <pdxpug(at)postgresql(dot)org>
Subject: Re: Meeting recap - Logic and Databases with Jeff Davis
Date: 2008-06-23 00:16:54
Message-ID: 1214180214.8973.79.camel@jdavis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pdxpug

On Sun, 2008-06-22 at 11:31 -0700, Randal L. Schwartz wrote:
> I'd argue that this is also wrong. You should not include "unknown" in your
> sum, even with this trick. Just filter it out with WHERE where you can,
> and rely on this "trick" only when filtering the rows is not an option.
>

In SQL, NULL doesn't always mean "unknown". See: OUTER JOIN and any
aggregate function (except COUNT).

I provided a link to the slides for my talk, and in there is a complete
example, in which we start out with no NULLs at all in our data, and yet
still run into precisely this problem. In that particular example, a
WHERE will *not* solve the problem, because aggregates (other than
COUNT) return NULL when there are no input rows (which I'd like to point
out is not an "unknown").

http://www.pgcon.org/2008/schedule/events/83.en.html

Regards,
Jeff Davis

In response to

Responses

Browse pdxpug by date

  From Date Subject
Next Message David E. Wheeler 2008-06-24 05:29:06 Re: Meeting recap - Logic and Databases with Jeff Davis
Previous Message Randal L. Schwartz 2008-06-22 18:31:01 Re: Meeting recap - Logic and Databases with Jeff Davis