| From: | Charles Albrecht <charlesa(at)pobox(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Ordering 'A', 'B', ..., 'Z', 'AA', 'AB', ... |
| Date: | 2002-02-20 21:28:36 |
| Message-ID: | p05101400b899c36e325d@[206.124.22.67] |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
At 4:47 PM -0300 2/20/2002, Jon Lapham wrote:
>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
>...
In transact-sql, I've used a structure something like:
ORDER BY
CASE WHEN TABLE.MYCOLUMN LIKE '__'
THEN TABLE.MYCOLUMN
ELSE ' ' || TABLE.MYCOLUMN END
The syntax may be a little different in pg, though.
It's also easy enough to do in Perl with a custom sort sub.
-Charles
--
Charles Albrecht Euonymic Solutions
charlesa(at)pobox(dot)com P.O. Box 300623
C>303.619.7596 F>978.334.3061 Denver, Colorado 80203-0623
http://www.euonymic.net/~charlesa/cv/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2002-02-20 21:31:27 | Re: [GENERAL] schema error upgrading from 7.1 to 7.2 |
| Previous Message | Bjrn Lundin | 2002-02-20 21:27:42 | Re: access database conversion |