Re: Syntax bug? Group by?

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Mark Woodward <pgsql(at)mohawksoft(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Syntax bug? Group by?
Date: 2006-10-17 21:19:37
Message-ID: 20061017211937.GD12030@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Oct 17, 2006 at 04:45:49PM -0400, Mark Woodward wrote:
> Well, this started out as a "huh, that's funny, that should work, is that
> a bug?" and is turning into a search through the SQL99 spec for a clear
> answer. I've already worked around it, but to me, at least, it seems it
> should work.

What you're asking for is difficult, not done by anyone else (so far
demostrated) and not mandated by the spec, so I don't see how it could
be construed a bug.

As for the spec, this is what I have from SQL2003:

7.12.15) If T is a grouped table, then let G be the set of grouping
columns of T. In each <value expression> contained in <select list>,
each column reference that references a column of T shall reference
some column C that is functionally dependent on G or shall be
contained in an aggregated argument of a <set function specification>
whose aggregation query is QS.

Which to me says that everything in the output is either grouped by or
part of an aggregate. That together with a statement elsewhere saying
that if no group by clause is present, GROUP BY () is implied seems to
seal it for me.

(BTW, the "functionally dependent" is new and postgresql only supports
the older SQL standards where C has to actually be a grouping column).

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-10-17 21:21:53 Re: Syntax bug? Group by?
Previous Message Tom Lane 2006-10-17 21:09:12 Re: query log corrupted-looking entries