I have tried several ways to trigger a 42P09 (ambiguous alias) error, but none of them succeeded.
This just "works", even when combined with
group by x
ororder by x
:select 1x, 1x;
This also "works":
with t as (select 1x, 1x, 1x) select * from t; select x from (with x as (select 1x) select x.x x from x group by x order by x) as x;
These only raise a [42712] (duplicate alias):
with t as (select 1x), t as (select 1x) select * from t; with t as (select 1x, 1x) select * from t, t;
These only raise a [42702] (ambiguous column):
select x from (select 1x, 1x) as t; with t1 as (select 1x), t2 as (select 1x) select x from t1, t2;
My google-foo didn't bring up any relevant results, either. I could only find mentions of this error existing, but noone seems to encounter it.
Is there any way to trigger a 42P09 error?
Based on @Adrian Klaver's answer, here's a SQL statement that actually yields a 42P09 error:
with t1 as (select 1x), t2 as (select 1y)
select * from t1 x CROSS JOIN
(t2 x CROSS JOIN lateral ( select * from t2 where t1.x = t2.y ) y) z;