Order by and strings

From: Fredric Fredricson <Fredric(dot)Fredricson(at)bonetmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Order by and strings
Date: 2010-02-09 00:09:56
Message-ID: 4B70A7D4.4000102@bonetmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi!
New to the list with a question that I cannot find the answer to in the
manual or on the internet but I suspect is trivial. If somebody could
point me in the correct direction I would be greatful.

This is what I do (condensed, of course):
# create table tmp ( x text ) ;
CREATE TABLE
# insert into tmp(x) values ('a'),('c'),('-b') ;
INSERT 0 3
# select * from tmp order by x ;
x
----
a
-b
c
(3 rows)

I would expect a string that start with a hyphen to be sorted before or
after 'a' and 'c' and not between them. I have tried with a few other
characters (space, opening parenthesis, etc) but the result is the same.

What I want is the strings sorted by their ascii (or UTF-8) values,
without some "smart" heuristic. How do I accomplish this?

I cannot find this described in the manual (it should be there!) or on
the net.

/Fredric

PS. 8.2, Fedora Linux

Attachment Content-Type Size
Fredric.Fredricson.vcf text/x-vcard 207 bytes

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Kerr 2010-02-09 00:41:11 vacuumdb ERROR: out of memory
Previous Message Ivan Sergio Borgonovo 2010-02-08 23:40:43 Re: How do I delete duplicate rows in a table?