Re: Aggregation (with GBY) is Relational Division

From: David Cressey <>
Date: Mon, 05 Jun 2006 16:24:02 GMT
Message-ID: <CUYgg.2121$LN1.271_at_trndny01>

"Marshall" <> wrote in message

> Actually, I had kind of a jolt reading something Bob Badour
> wrote recently about defining aggregates as either a fold
> or an expression written in terms of folds. (He did not use
> the term "fold".) Thus, avg(x) can be defined as simply
> sum(x) / count().

I disagree. avg(x) can be defined as simply sum(x) / count(x).

This may seem like nitpicking. I think it's reasonably important.

If you do select avg(x), sum(x)/count(*), sum(x)/count(x) from some_view

you are going to get a difference when there are rows in the view that contain NULL in the x column. Try it and see.

This relates to a comment about managing missing data in SQL that I didn't take very much to heart.

PS: can you point me to a web site that will explain "fold" to me? Received on Mon Jun 05 2006 - 18:24:02 CEST

Original text of this message