pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mario Splivalo <mario.splivalo@megafon.hr>
To: Mikel Lindsaar <raasdnil@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Ordering a name list and ignoring whitespace
Date: Thu, 16 Apr 2009 13:02:44 +0200
Message-ID: <49E71054.1030607@megafon.hr> (raw)
In-Reply-To: <57a815bf0904160351v7282fd00p7b7d9690ca48dcff@mail.gmail.com>
References: <57a815bf0904160351v7282fd00p7b7d9690ca48dcff@mail.gmail.com>

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



view thread (3+ messages)  latest in thread

Message-ID: <49E71054.1030607@megafon.hr>
Permalink:  ../49E71054.1030607@megafon.hr/
Also on:    postgresql.org/message-id/49E71054.1030607@megafon.hr

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mario.splivalo@megafon.hr, raasdnil@gmail.com
  Subject: Re: Ordering a name list and ignoring whitespace
  In-Reply-To: <49E71054.1030607@megafon.hr>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox