Sunday, June 22, 2008

Re: [pdxpug] Meeting recap - Logic and Databases with Jeff Davis

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


--
Sent via pdxpug mailing list (pdxpug@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pdxpug

No comments: