| From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
|---|---|
| To: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
| Cc: | PALAYRET Jacques <jacques(dot)palayret(at)meteo(dot)fr>, pgsql-general(at)lists(dot)postgresql(dot)org |
| Subject: | Re: PostgreSQL query with FULL OUTER JOIN and subquery using column of GROUP BY expression ERROR: subquery uses ungrouped column from outer query |
| Date: | 2026-02-25 16:20:18 |
| Message-ID: | CAKFQuwY27TZSERWdmC+=RO+B86KAOSW+CeJSSL52eUZQLYZsrA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Wed, Feb 25, 2026 at 9:00 AM Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
wrote:
> 1) Why FROM (SELECT * FROM t1 ) AS t1 instead of just FROM t1?
> Same for JOIN (SELECT * FROM t3 ) t3
>
Seems immaterial. It's just a consequence of simplifying the original
problem query. If it is consequential that would seem buggy.
> 2) Why are the field names not table qualified e.g. t2.id, t3.id, etc?
>
Because of the USING clause, those references shouldn't exist in the main
query.
> 3) What is the desired outcome?
>
For the engine to realize the 'id' in the group by and the 'id' in the
scalar subquery are the same 'id' - the one produced by the USING clause,
not either of the t2 or t3 ids.
My first impression is that this is a bug. Especially since the query
apparently executes in both left-join and right-join modes.
David J.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | PALAYRET Jacques | 2026-02-25 16:42:03 | Re: PostgreSQL query with FULL OUTER JOIN and subquery using column of GROUP BY expression ERROR: subquery uses ungrouped column from outer query |
| Previous Message | PALAYRET Jacques | 2026-02-25 16:00:11 | Re: PostgreSQL query with FULL OUTER JOIN and subquery using column of GROUP BY expression ERROR: subquery uses ungrouped column from outer query |