Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YDbX4-0002s0-VV for pgsql-bugs@arkaria.postgresql.org; Tue, 20 Jan 2015 16:19:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YDbX4-00087i-8w for pgsql-bugs@arkaria.postgresql.org; Tue, 20 Jan 2015 16:19:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YDMDw-0004Zu-AO for pgsql-bugs@postgresql.org; Mon, 19 Jan 2015 23:59:12 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YDMDn-0003Oe-U1 for pgsql-bugs@postgresql.org; Mon, 19 Jan 2015 23:59:10 +0000 MIME-Version: 1.0 Subject: BUG #12603: Results Ordering not correct To: pgsql-bugs@postgresql.org From: aruggiero@codarex.com Date: Mon, 19 Jan 2015 23:58:37 +0000 Message-ID: <20150119235837.5765.61481@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 The following bug has been logged on the website: Bug reference: 12603 Logged by: Antonio Ruggiero Email address: aruggiero@codarex.com PostgreSQL version: 9.2.9 Operating system: Windows 7 SP1 Description: Summary: A field is Integer but results ordered as if it is text. /* START */ DROP TABLE IF EXISTS bug_test; create table Bug_test (businessunit integer, businessunitname character varying(15)); INSERT INTO bug_test VALUES (10,'North'); INSERT INTO bug_test VALUES (20,'NorthEast'); INSERT INTO bug_test VALUES (100,'East'); INSERT INTO bug_test VALUES (110,'SouthEast'); INSERT INTO bug_test VALUES (2000,'South'); INSERT INTO bug_test VALUES (2100,'SouthWest'); INSERT INTO bug_test VALUES (10000,'West'); INSERT INTO bug_test VALUES (10100,'NorthWest'); SELECT DISTINCT businessunit AS bu_id, '('||businessunit::TEXT||')'||businessunitname as businessunit FROM bug_test ORDER BY businessunit; /* Output */ /* --Notice results ordered as if businessunit is TEXT-- bu_id, businessunit integer, text 10;'(10)North' 100;'(100)East' 10000;'(10000)West' 10100;'(10100)NorthWest' 110;'(110)SouthEast' 20;'(20)NorthEast' 2000;'(2000)South' 2100;'(2100)SouthWest' */ SELECT DISTINCT businessunit AS bu_id, '('||businessunit::TEXT||')'||businessunitname as businessunit FROM bug_test ORDER BY 1; /* Output */ /* --Notice results ordered as if businessunit is INTEGER-- bu_id, businessunit integer, text 10;'(10)North' 20;'(20)NorthEast' 100;'(100)East' 110;'(110)SouthEast' 2000;'(2000)South' 2100;'(2100)SouthWest' 10000;'(10000)West' 10100;'(10100)NorthWest' */ DROP TABLE IF EXISTS bug_test; /* END */ -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs