The following bug has been logged on the website:
Bug reference: 18542
Logged by: Aleksandr Novozhilov
Email address: ivningman(at)gmail(dot)com
PostgreSQL version: 16.1
Operating system: Windows
Description:
select z as y from
(select 1 as z) x
order by y + 1
That query finishes with error:
ERROR: column "y" does not exist
Position: 48
But wrapping it with select works fine:
select * from (select z as y from
(select 1 as z) x) c
order by y + 1