Re: BUG #1265: sorting by (ORDER BY) result of an operation for names assigned by AS does not work

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Ansis" <ataols(at)latnet(dot)lv>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1265: sorting by (ORDER BY) result of an operation for names assigned by AS does not work
Date: 2004-09-22 15:04:34
Message-ID: 11828.1095865474@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"PostgreSQL Bugs List" <pgsql-bugs(at)postgresql(dot)org> writes:
> The query:
> SELECT id, lang as name, (SELECT lang FROM participants WHERE id =
> event.participant) as pname FROM event ORDER BY name || pname;
> returns an error:
> ERROR: column "name" does not exist

It's not a bug. Per
http://www.postgresql.org/docs/7.4/static/sql-select.html
under "ORDER BY Clause"

: 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.

The ability to reference an output column in ORDER BY is actually a legacy
feature that was removed in the SQL99 spec.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Gaetano Mendola 2004-09-22 16:46:30 Re: Error with PostgreSQL 8.0 beta 2, in "make check" on Mac OS
Previous Message PostgreSQL Bugs List 2004-09-22 14:31:13 BUG #1265: sorting by (ORDER BY) result of an operation for names assigned by AS does not work