Re: Ordering a name list and ignoring whitespace

From: Mario Splivalo <mario(dot)splivalo(at)megafon(dot)hr>
To: Mikel Lindsaar <raasdnil(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Ordering a name list and ignoring whitespace
Date: 2009-04-16 11:02:44
Message-ID: 49E71054.1030607@megafon.hr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message ShuA 2009-04-16 11:29:38 Need a script that bakes INSERT script from SELECT results
Previous Message Mikel Lindsaar 2009-04-16 10:51:37 Ordering a name list and ignoring whitespace