From: hubert depesz lubaczewski <depesz@depesz.com>
To: pgsql-bugs@lists.postgresql.org
Subject: order by alias - doesn't work sometimes?
Date: Tue, 14 Oct 2025 16:50:56 +0200
Message-ID: <aO5jUGlQgBBAOp4_@depesz.com> (raw)
Hi,
It very well might not be a bug, but it caught me by surprise.
Tested on Pg 19 from git head:
=$ select unnest( ARRAY['d', 'c', 'a'] ) x order by x;
x
───
a
c
d
(3 rows)
Works, and shows that I can order by alias name of column that is generated by srf.
But:
=$ select unnest( ARRAY['d', 'c', 'a'] ) x order by x <> 'a';
ERROR: column "x" does not exist
LINE 1: select unnest( ARRAY['d', 'c', 'a'] ) x order by x <> 'a';
^
Obviously I can put the unnest() call in from, and then it works, but
I'm curious, why we can `order by x`, but not `order by x <> 'a'` ?
Best regards,
depesz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: depesz@depesz.com, pgsql-bugs@lists.postgresql.org
Subject: Re: order by alias - doesn't work sometimes?
In-Reply-To: <aO5jUGlQgBBAOp4_@depesz.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox