Re: Ordering in SELECT statement

From: PFC <lists(at)peufeu(dot)com>
To: "Michael Glaesemann" <grzm(at)seespotcode(dot)net>, "kdealba(at)uaaan(dot)mx" <kdealba(at)uaaan(dot)mx>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Ordering in SELECT statement
Date: 2007-06-26 21:42:39
Message-ID: op.tujs9dbgcigqcu@apollo13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On Jun 26, 2007, at 14:41 , kdealba(at)uaaan(dot)mx wrote:
>> and what I need is the following ("old fashion", that is, the "SPACE"
>> is another character whose ASCII value is before any other LATIN
>> letter's!!)
>> AB CD
>> AB EF
>> ABAB
>> ABD E

What you don't want :

peufeu=> SELECT column1 FROM (VALUES ('ABCD'), ('A BCD'), ('abcd'),
('ABcd'), ('AB'), ('AbC d')) AS foo ORDER BY column1;
column1
---------
AB
abcd
AbC d
ABcd
ABCD
A BCD
(6 lignes)

What you want :

peufeu=> SELECT column1 FROM (VALUES ('ABCD'), ('A BCD'), ('abcd'),
('ABcd'), ('AB'), ('AbC d')) AS foo ORDER BY string_to_array( column1, '
' );
column1
---------
A BCD
AB
AbC d
abcd
ABcd
ABCD
(6 lignes)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message PFC 2007-06-26 22:00:48 Re: a JOIN on same table, but 'slided over'
Previous Message Willy-Bas Loos 2007-06-26 21:42:00 Re: escaped rolenames in pg_has_role