Re: order by query wrong result - Mailing list pgsql-admin

From Matheus de Oliveira
Subject Re: order by query wrong result
Date
Msg-id CAJghg4KGCAKJn=APRbT6odp82NMg4FoUp7_MYxpz5hzx53xyGg@mail.gmail.com
Whole thread Raw
In response to Re: order by query wrong result  (Silvio Brandani <silvio.brandani@tech.sdb.it>)
Responses Re: order by query wrong result  (Silvio Brandani <silvio.brandani@tech.sdb.it>)
List pgsql-admin

On Wed, Nov 19, 2014 at 2:36 PM, Silvio Brandani <silvio.brandani@tech.sdb.it> wrote:
CREATE OR REPLACE FUNCTION cleanup(text)
RETURNS text AS $
SELECT replace(replace(replace($1, ' ','x'),'-','x'),'.','x')
$ LANGUAGE sql;

and I get correct result :

select name
from prva
where name ilike 'savino del bene s%'
order by upper(cleanup(name));


If you are trying to get smarter than the collate, don't you think it would be a good idea to use C collate?

e.g. ORDER BY upper(name) COLLATE "C";

You can even use a cleanup like to convert things that you want to consider the same (as using unaccent). Although it would make harder to move with and without accent to the same place.

Regards,
--
Matheus de Oliveira
Analista de Banco de Dados
Dextra Sistemas - MPS.Br nível F!
www.dextra.com.br/postgres

pgsql-admin by date:

Previous
From: Silvio Brandani
Date:
Subject: Re: order by query wrong result
Next
From: Silvio Brandani
Date:
Subject: Re: order by query wrong result