X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 51D1C528C9 for ; Mon, 16 May 2005 16:12:34 -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 97288-08 for ; Mon, 16 May 2005 19:12:29 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 7AE1752800 for ; Mon, 16 May 2005 16:12:27 -0300 (ADT) Received: (qmail 13860 invoked from network); 16 May 2005 21:12:55 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 16 May 2005 21:12:55 +0200 To: "David B" , pgsql-sql@postgresql.org Subject: Re: ORDER BY handling mixed integer and varchar values References: Message-ID: Date: Mon, 16 May 2005 21:12:28 +0200 From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/112 X-Sequence-Number: 21425 > Is there any elegent query you folks can think of that combines the > two so I can one query that has alpha sorting on alpha categories and > numeric sorting on numeric values that are in the same column?? solution 1 (fast) make a separate column which contains the integer value (updated via a trigger) or NULL if it's a textual value, then sort on it solution 2 order by the string padded to a fixed length by adding spaces to the left : (here an underscore is a space): ____1 ___10 _ABCD I think there's a LPAD function (look in the docs) to do that... you can use only the first N (like 10) chars of the string...