Re: BUG #12603: Results Ordering not correct

From: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #12603: Results Ordering not correct
Date: 2015-01-20 17:27:11
Message-ID: 1421774831530-5834765.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Guillaume Lelarge-3 wrote
>> SELECT DISTINCT businessunit AS bu_id,
>> '('||businessunit::TEXT||')'||businessunitname as businessunit FROM
> bug_test
>> ORDER BY businessunit;
>
> It is text. You renamed the second column businessunit.

To be more specific, the ORDER BY chooses an output column name before an
input column name.

http://www.postgresql.org/docs/9.1/static/sql-select.html

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

David J.

--
View this message in context: http://postgresql.nabble.com/BUG-12603-Results-Ordering-not-correct-tp5834749p5834765.html
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Asif Naeem 2015-01-20 17:41:41 Re: pg_upgrade failure on Windows Server
Previous Message Guillaume Lelarge 2015-01-20 17:11:58 Re: BUG #12603: Results Ordering not correct