Re: Sorting problem

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Ruggero <ruggero(dot)maria(dot)rossi(at)libero(dot)it>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Sorting problem
Date: 2004-07-16 19:14:38
Message-ID: 20040716120950.J75128@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, 12 Jul 2004, Ruggero wrote:

> Hi all,
> I have a problem sorting varchar fields.
> I will explain the problem with a simple example:
>
> this query
> select '##10' as sortfield
> union
> select '###1' as sortfield
> order by sortfield
> produces this correct output:
> '###1'
> '##10'
>
> but this one
>
> select '##10############--------####79909999' as sortfield
> union
> select '###1############--------####79909999' as sortfield
> order by sortfield
> produces this wrong output:
> '##10############--------####79909999'
> '###1############--------####79909999'
>
> I'm using postgresql 7.4.3 on Suse Linux 9.1.
> I created my db using: initdb --pgdata=../data/ --encoding=LATIN1
> --lc-collate=it_IT --lc-ctype=it_IT
>
> Any suggestion?

it_IT looks like it's sorting based on the strings with the symbols
removed. I get similar behavior on my system using the unix sort command
with it_IT. This looks like it's a mismatch between what you want and the
collation you've provided.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Peter Wang 2004-07-16 20:18:13 BYTEA output presentation
Previous Message Tom Lane 2004-07-16 14:34:07 Re: Problem in age on a dates interval