Re: ORDER BY is case insensitive - Mailing list pgsql-sql

From Gerardo Herzig
Subject Re: ORDER BY is case insensitive
Date
Msg-id 4C212BD8.5040102@fmed.uba.ar
Whole thread Raw
In response to ORDER BY is case insensitive  (Bryan White <nicktook@gmail.com>)
Responses Re: ORDER BY is case insensitive  (Bryan White <nicktook@gmail.com>)
List pgsql-sql
Bryan White wrote:
> I was suprised to find out that ORDER BY is case insensitive.  Is
> there a way to do a case sensitive ORDER BY clause?
> 
> This transcript demonstrates what I am seeing:
> 
> $ createdb bryan
> $ psql bryan
> psql (8.4.4)
> Type "help" for help.
> 
> bryan=# create table t (f text);
> CREATE TABLE
> bryan=# insert into t (f) values ('a');
> INSERT 0 1
> bryan=# insert into t (f) values ('b');
> INSERT 0 1
> bryan=# insert into t (f) values ('c');
> INSERT 0 1
> bryan=# insert into t (f) values ('B');
> INSERT 0 1
> bryan=# select * from t order by f;
>  f
> ---
>  a
>  b
>  B
>  c
> (4 rows)

Well. Im not really surprised. The column is text, so it sound
reasonable to order by its *text* representation. You may want to order
from its *ascii* value instead:

regression=# SELECT * from test order by ascii(data);data
------Babc
(4 rows)

Or similar...Wich order are you expecting to see?

HTH
Gerardo


pgsql-sql by date:

Previous
From: Bryan White
Date:
Subject: ORDER BY is case insensitive
Next
From: Tom Lane
Date:
Subject: Re: ORDER BY is case insensitive