Re: 7.3 "group by" issue

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>, Dan Langille <dan(at)langille(dot)org>
Cc: Chad Thompson <chad(at)weblinkservices(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: 7.3 "group by" issue
Date: 2003-02-22 19:34:45
Message-ID: 200302221134.45226.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Peter,

> This does not work because the first select list item references a column
> inside a join, which is not (necessarily) mathematically identical to the
> column that arrives outside of the join and is in the GROUP BY clause.
> (Think of an outer join: the column outside the join might contain added
> null values. Of course you are using an inner join, but the constructs
> work the same either way.)

Hmmm ... I don't see that. I can see that it might be practically
difficult-to-impossible to make the planner distinguish between cases where
the columns in the select list are different from the columns in the JOIN
series and when they aren't, but as a theory issue I just don't buy it.

What Dan's doing is:

SELECT a.c1, count(a.c2)
FROM a JOIN b
WHERE b.c5 = x
GROUP BY c1

In a case like this, a.c1 == c1 without possibility of ambiguity. The only
difference is whether or not a table qualifier is used on the name, which in
theory should *only* make a difference when there are more than one table in
the query with that column name.

So if you're saying that that kind of equivalency is a challenging parser
implementation issue, then I'm with you. If you're saying its a SQL theory
issue, though, I don't agree at all.

--
Josh Berkus
Aglio Database Solutions
San Francisco

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Hubert depesz Lubaczewski 2003-02-23 00:14:42 how to return ONE single record from a function in plpgsql?
Previous Message Stephan Szabo 2003-02-22 17:41:46 Re: [SQL] 7.3 GROUP BY differs from 7.2