Thread: ORDER BY works stranke

ORDER BY works stranke

From
Uro Gruber
Date:
Hi!

I noticed that order by works strange

if i use ORDER BY some field i get result like this

Mytest
Test
arethistest

But it supposed to be

arethistest
Mytest
Test


Is it possible to reorder this alphabetical but not to use caps.

thanks

--
Uroš



Re: ORDER BY works stranke

From
"Dan Wilson"
Date:
ORDER BY UPPER(somefield)  will do what you are wanting.

-Dan

----- Original Message -----
From: "Uro Gruber" <uros@sir-mag.com>
To: <pgsql-general@postgresql.org>
Sent: Friday, January 12, 2001 4:06 PM
Subject: [GENERAL] ORDER BY works stranke


> Hi!
>
> I noticed that order by works strange
>
> if i use ORDER BY some field i get result like this
>
> Mytest
> Test
> arethistest
>
> But it supposed to be
>
> arethistest
> Mytest
> Test
>
>
> Is it possible to reorder this alphabetical but not to use caps.
>
> thanks
>
> --
> Uroš
>
>


Re: ORDER BY works stranke

From
Bruno Wolff III
Date:
On Sat, Jan 13, 2001 at 01:06:00AM +0100,
  Uro Gruber <uros@sir-mag.com> wrote:
> Hi!
>
> I noticed that order by works strange
>
> if i use ORDER BY some field i get result like this
>
> Mytest
> Test
> arethistest
>
> But it supposed to be
>
> arethistest
> Mytest
> Test

This seems to depend on your locale. As far as I could tell the local
strcmp function is used to compare strings. In my locale lowercase and
uppercase are treated as similar and only distinguish between them when
the strings are otherwise identical. Special characters also have unusal
affects for people expecting comparisons based on ascii codes.
If someone knows of a good source of documentation for how the comparison
is done in the default locale in redhat linux systems, I would be interested
in hearing about it.