Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id E9E736321AE for ; Tue, 22 Jun 2010 18:22:14 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 54363-05 for ; Tue, 22 Jun 2010 21:22:06 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.fmed.uba.ar (mail.fmed.uba.ar [157.92.152.1]) by mail.postgresql.org (Postfix) with ESMTP id DF1CD6335A8 for ; Tue, 22 Jun 2010 18:22:07 -0300 (ADT) Received: from [157.92.152.105] (unknown [157.92.152.105]) by mail.fmed.uba.ar (Postfix) with ESMTP id EEE38490F71; Tue, 22 Jun 2010 17:20:21 -0300 (ART) Message-ID: <4C212BD8.5040102@fmed.uba.ar> Date: Tue, 22 Jun 2010 18:32:08 -0300 From: Gerardo Herzig User-Agent: Thunderbird 2.0.0.6 (X11/20070801) MIME-Version: 1.0 To: Bryan White CC: pgsql-sql@postgresql.org Subject: Re: ORDER BY is case insensitive References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.011 tagged_above=-5 required=5 tests=BAYES_40=-0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201006/71 X-Sequence-Number: 34262 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 ------ B a b c (4 rows) Or similar...Wich order are you expecting to see? HTH Gerardo