Re: Ordering 'A', 'B', ..., 'Z', 'AA', 'AB', ... - Mailing list pgsql-general

From Peter Darley
Subject Re: Ordering 'A', 'B', ..., 'Z', 'AA', 'AB', ...
Date
Msg-id NNEAICKPNOGDBHNCEDCPKELOCEAA.pdarley@kinesis-cem.com
Whole thread Raw
In response to Ordering 'A', 'B', ..., 'Z', 'AA', 'AB', ...  (Jon Lapham <lapham@extracta.com.br>)
List pgsql-general
Jon,
    How about "order by char_length(field), field"
Thanks,
Peter Darley

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org]On Behalf Of Jon Lapham
Sent: Wednesday, February 20, 2002 11:47 AM
To: pgsql-general@postgresql.org
Subject: [GENERAL] Ordering 'A', 'B', ..., 'Z', 'AA', 'AB', ...


Hello folks-

Does anyone have a suggestion on how to order a varchar(2) column
containing values like: 'A', 'B', ..., 'Z', 'AA', 'AB', ...

What I would like to to return the tuples in this order:
A
B
C
...
X
Y
Z
AA
AB
...

Instead of:
A
AA
AB
...
B
BA
BB
...

While I would prefer to do the ordering in SQL, my application is
written perl, so I could always do the ordering perl-ically.

Thanks in advance!

--

-**-*-*---*-*---*-*---*-----*-*-----*---*-*---*-----*-----*-*-----*---
  Jon Lapham
  Extracta Moléculas Naturais, Rio de Janeiro, Brasil
  email: lapham@extracta.com.br      web: http://www.extracta.com.br/
***-*--*----*-------*------------*--------------------*---------------


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


pgsql-general by date:

Previous
From: Cindy
Date:
Subject: Re: question on function definitions/casts
Next
From: "Rodney Broom"
Date:
Subject: Ping