Re: order by query wrong result

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Wed, Nov 19, 2014 at 2:36 PM, Silvio Brandani <silvio.brandani@xxxxxxxxxxx> 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


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux