Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 20668634AC1 for ; Thu, 16 Apr 2009 08:02:57 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 32000-09 for ; Thu, 16 Apr 2009 08:02:48 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from megafon.hr (megafon.hr [213.202.104.5]) by mail.postgresql.org (Postfix) with ESMTP id CDD15634ADC for ; Thu, 16 Apr 2009 08:02:54 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by megafon.hr (Postfix) with ESMTP id 6A1847EC002; Thu, 16 Apr 2009 13:02:51 +0200 (CEST) X-Virus-Scanned: ClamAV at megafon.hr Received: from megafon.hr ([127.0.0.1]) by localhost (localhost.localdomain [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nUEv35OpxBkl; Thu, 16 Apr 2009 13:02:43 +0200 (CEST) Received: from [192.168.1.94] (unknown [212.92.194.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: mike) by megafon.hr (Postfix) with ESMTP id ADC567EC004; Thu, 16 Apr 2009 13:02:43 +0200 (CEST) Message-ID: <49E71054.1030607@megafon.hr> Date: Thu, 16 Apr 2009 13:02:44 +0200 From: Mario Splivalo User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: Mikel Lindsaar CC: pgsql-sql@postgresql.org Subject: Re: Ordering a name list and ignoring whitespace References: <57a815bf0904160351v7282fd00p7b7d9690ca48dcff@mail.gmail.com> In-Reply-To: <57a815bf0904160351v7282fd00p7b7d9690ca48dcff@mail.gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/87 X-Sequence-Number: 32433 Mikel Lindsaar wrote: > Hi all, > > Doing some googling and looking through the docs, I can't find an > obvious way to do this beside post processing after the query (which I > am trying to avoid). > > I'm trying to select a list of names in alphabetical order but > ignoring the whitespace. > > So for example, the name "La Combe" should come after "Lace" but > before "Lacs..." > > Any ideas? Could you do it like this: SELECT replace(name_column, ' ', '') AS name_replaced FROM your_table_name ORDER BY name_replaced This can get a bit slowish if your table has quite a number of rows. Mike