X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0CDA6DA7F7 for ; Thu, 20 Oct 2005 00:33:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 56826-02 for ; Thu, 20 Oct 2005 03:33:18 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id BD410DA7F3 for ; Thu, 20 Oct 2005 00:33:17 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j9K3XEqe003688; Wed, 19 Oct 2005 23:33:15 -0400 (EDT) To: Bryce W Nesbitt Cc: pgsql-sql@postgresql.org Subject: Re: casting character varying to integer - order by numeric sort In-reply-to: <4356EC5D.4080706@obviously.com> References: <4356EC5D.4080706@obviously.com> Comments: In-reply-to Bryce W Nesbitt message dated "Wed, 19 Oct 2005 18:01:17 -0700" Date: Wed, 19 Oct 2005 23:33:14 -0400 Message-ID: <3687.1129779194@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200510/231 X-Sequence-Number: 23084 Bryce W Nesbitt writes: > SELECT username,last_name > FROM eg_member ORDER BY username::integer; > But postgres 7 rejects this with "ERROR: cannot cast type character > varying to integer". As a general rule, you need to be more specific than that about which version you are working with ;-) You may find that username::text::integer will work, depending on which 7.x this actually is. regards, tom lane