ORDER BY: lexicographic ordering of names

Started by Bryan Hergerabout 17 years ago4 messagesgeneral
Jump to latest
#1Bryan Herger
bryanh@autonomy.com

All,

I am porting a database from MS SQL Server to Postgres. One of the
tables contains a list of names, which I would like to list
alphabetically. I noticed in the "O" names the following difference:

MSSQL:

O'Daniel

O'Neill

Oliveira

Oliver

While PGSQL sorts as if the apostrophe was not there:

O'Daniel

Oliveira

Oliver

O'Neill

I think the MSSQL output is more correct for listing names
alphabetically. How can I configure or query PGSQL to get the same sort
order?

Thanks,

Bryan

#2Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Bryan Herger (#1)
Re: ORDER BY: lexicographic ordering of names

Bryan Herger wrote:

I am porting a database from MS SQL Server to Postgres. One of the
tables contains a list of names, which I would like to list
alphabetically. I noticed in the "O" names the following difference:

Note to whoever answers: this is a frequent question, so consider adding
your answer to the FAQ on the wiki,

http://wiki.postgresql.org/wiki/FAQ

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alvaro Herrera (#2)
Re: ORDER BY: lexicographic ordering of names

Alvaro Herrera <alvherre@commandprompt.com> writes:

Bryan Herger wrote:

I am porting a database from MS SQL Server to Postgres. One of the
tables contains a list of names, which I would like to list
alphabetically. I noticed in the "O" names the following difference:

Note to whoever answers: this is a frequent question, so consider adding
your answer to the FAQ on the wiki,

Done...
http://wiki.postgresql.org/wiki/FAQ#How_do_I_change_the_sort_ordering_of_textual_data.3F

regards, tom lane

#4Edoardo Panfili
edoardo@aspix.it
In reply to: Bryan Herger (#1)
Re: ORDER BY: lexicographic ordering of names

Il 18-03-2009 21:32, Bryan Herger ha scritto:

All,

I am porting a database from MS SQL Server to Postgres. One of the
tables contains a list of names, which I would like to list
alphabetically. I noticed in the �O� names the following difference:

MSSQL:
O�Daniel
O�Neill
Oliveira
Oliver

While PGSQL sorts as if the apostrophe was not there:
O�Daniel
Oliveira
Oliver
O�Neill

I think the MSSQL output is more correct for listing names
alphabetically. How can I configure or query PGSQL to get the same sort
order?

Some time ago I had a problem with string sorting related to my locale
(but with "*" instead of "'"), now all works adding
"ORDER BY column USING ~<~".

I did I try with your data but I obtain the same sorting of MSSQL both
in my locale and using ~<~.

Edoardo