Re: Denormalizing during select - Mailing list pgsql-sql

From Tom Lane
Subject Re: Denormalizing during select
Date
Msg-id 12195.1046538812@sss.pgh.pa.us
Whole thread Raw
In response to Re: Denormalizing during select  (Edmund Lian <no.spam@address.com>)
List pgsql-sql
Edmund Lian <no.spam@address.com> writes:
> Answering my own question: kind of. The problem with custom aggregates
> is that they need to be used with a "group by" clause, and this means
> that the select cannot return columns that are not aggregates of some
> kind. What I'm trying to return are rows that are a combination of
> columns and aggregates.

This strikes me as evidence of fuzzy thinking.  What sets of rows are
the aggregates taken over?  Which column values within those sets of
rows do you expect the non-aggregated column references to return?
If the columns aren't the ones grouped by, seems like you have an
inherently undefined result.

If you know for some reason that there will be only one unique value
of a column in a grouped row set, or you don't actually much care which
one you get, then you could use MIN() or MAX() on the column reference
to make it look like a kosher query.
        regards, tom lane


pgsql-sql by date:

Previous
From: Rod Taylor
Date:
Subject: Re: Denormalizing during select
Next
From: Greg Stark
Date:
Subject: Re: Denormalizing during select