Re: BUG #4030: Inconsistency: ORDER BY clauses involving column aliases

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Dave Gurnell" <d(dot)j(dot)gurnell(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4030: Inconsistency: ORDER BY clauses involving column aliases
Date: 2008-03-14 14:42:09
Message-ID: 17223.1205505729@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Dave Gurnell" <d(dot)j(dot)gurnell(at)gmail(dot)com> writes:
> Run a query ordered on an expression involving these aliases:

> test=# select x.a as xa, x.b as xb, x.c as xc from numbers as x order by
> (xa + xb + xc);
> ERROR: column "xa" does not exist
> LINE 1: ... x.b as xb, x.c as xc from numbers as x order by (xa + xb +
> ...

> Is this expected behaviour or is it a bug?

It's expected and documented. No, it isn't very consistent :-(.
We're trying to support both the SQL92 and SQL99 approaches to ORDER BY,
and they're not the same.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message RGF 2008-03-14 20:53:08 BUG #4035: sql table aliases do not work
Previous Message divya shree 2008-03-14 09:19:38 Further problems