Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YDcaD-0005EV-G8 for pgsql-bugs@arkaria.postgresql.org; Tue, 20 Jan 2015 17:27:17 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YDcaC-0006b5-P0 for pgsql-bugs@arkaria.postgresql.org; Tue, 20 Jan 2015 17:27:16 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YDcaC-0006aq-3A for pgsql-bugs@postgresql.org; Tue, 20 Jan 2015 17:27:16 +0000 Received: from mwork.nabble.com ([162.253.133.43]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YDca8-0005xP-HD for pgsql-bugs@postgresql.org; Tue, 20 Jan 2015 17:27:13 +0000 Received: from msam.nabble.com (unknown [162.253.133.85]) by mwork.nabble.com (Postfix) with ESMTP id EBEA41122AC3 for ; Tue, 20 Jan 2015 09:27:11 -0800 (PST) Date: Tue, 20 Jan 2015 10:27:11 -0700 (MST) From: David G Johnston To: pgsql-bugs@postgresql.org Message-ID: <1421774831530-5834765.post@n5.nabble.com> In-Reply-To: References: <20150119235837.5765.61481@wrigleys.postgresql.org> Subject: Re: BUG #12603: Results Ordering not correct MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -0.3 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs