Re: 7.3 "group by" issue

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: 7.3 "group by" issue
Дата
Msg-id Pine.LNX.4.44.0302230245070.2308-100000@peter.localdomain
обсуждение исходный текст
Ответ на Re: 7.3 "group by" issue  (Josh Berkus <josh@agliodbs.com>)
Ответы Re: 7.3 "group by" issue  (Josh Berkus <josh@agliodbs.com>)
Список pgsql-sql
Josh Berkus writes:

> 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.

Consider JOIN to be a black-box function, then you'd be writing something
like

SELECT a.c1, count(a.c2)
FROM func(a, b) AS r (c1, c2, c3, c4, c5)
WHERE b.c5 = x
GROUP BY c1; -- <== refers to r.c1

Clearly in this case you cannot claim that in general a.c1 == r.c1.

If the func() is an inner join, then the claim is true, but if it's an
outer join it's not.  The scoping rules for inner and outer joins are the
same, and that might be considered a good thing.

-- 
Peter Eisentraut   peter_e@gmx.net



В списке pgsql-sql по дате отправления:

Предыдущее
От: Neil Conway
Дата:
Сообщение: Re: sql question after upgrade
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: sql question after upgrade