pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedOrdering a name list and ignoring whitespace
3+ messages / 3 participants
[nested] [flat]
* Ordering a name list and ignoring whitespace
@ 2009-04-16 10:51 Mikel Lindsaar <raasdnil@gmail.com>
2009-04-16 11:02 ` Re: Ordering a name list and ignoring whitespace Mario Splivalo <mario.splivalo@megafon.hr>
2009-04-16 14:13 ` Re: Ordering a name list and ignoring whitespace Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 3+ messages in thread
From: Mikel Lindsaar @ 2009-04-16 10:51 UTC (permalink / raw)
To: pgsql-sql
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?
Mikel
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Ordering a name list and ignoring whitespace
2009-04-16 10:51 Ordering a name list and ignoring whitespace Mikel Lindsaar <raasdnil@gmail.com>
@ 2009-04-16 11:02 ` Mario Splivalo <mario.splivalo@megafon.hr>
1 sibling, 0 replies; 3+ messages in thread
From: Mario Splivalo @ 2009-04-16 11:02 UTC (permalink / raw)
To: Mikel Lindsaar <raasdnil@gmail.com>; +Cc: 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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Ordering a name list and ignoring whitespace
2009-04-16 10:51 Ordering a name list and ignoring whitespace Mikel Lindsaar <raasdnil@gmail.com>
@ 2009-04-16 14:13 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 3+ messages in thread
From: Tom Lane @ 2009-04-16 14:13 UTC (permalink / raw)
To: Mikel Lindsaar <raasdnil@gmail.com>; +Cc: pgsql-sql
Mikel Lindsaar <raasdnil@gmail.com> writes:
> 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..."
FWIW, this would probably happen automatically if you were using a
non-C locale. I'm not sure that's really a good solution, because
switching to a different locale would affect every sort operation
you ever do. But it's an alternative to consider.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2009-04-16 14:13 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-04-16 10:51 Ordering a name list and ignoring whitespace Mikel Lindsaar <raasdnil@gmail.com>
2009-04-16 11:02 ` Mario Splivalo <mario.splivalo@megafon.hr>
2009-04-16 14:13 ` Tom Lane <tgl@sss.pgh.pa.us>
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