Re: order by alias - doesn't work sometimes?

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: order by alias - doesn't work sometimes?
Date: 2025-10-14 15:46:23
Message-ID: aO5wT-h2C5WACgaq@depesz.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Oct 14, 2025 at 11:10:31AM -0400, Tom Lane wrote:
> ORDER BY output-column-alias is a messy hangover from SQL92.
> In later SQL versions, identifiers in ORDER BY have the same
> interpretation as in WHERE and other clauses, namely they are
> columns sourced by the FROM clause. Supporting both interpretations
> makes for a lot of ambiguity, so we only allow the old interpretation
> in exactly the case required by SQL92, namely "ORDER BY identifier".
>
> This is documented ...

Well, now I understand this:

>> Each expression can be the name or ordinal number of an output column
>> (SELECT list item), or it can be an arbitrary expression formed from
>> input-column values.

better. Thanks.

Best regards,

depesz

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Yuri Zamyatin 2025-10-14 15:51:02 Re: BUG #19078: Segfaults in tts_minimal_store_tuple() following pg_upgrade
Previous Message Tom Lane 2025-10-14 15:10:31 Re: order by alias - doesn't work sometimes?