Re: Ordering 'A', 'B', ..., 'Z', 'AA', 'AB', ...

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Charles Albrecht <charlesa(at)pobox(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Ordering 'A', 'B', ..., 'Z', 'AA', 'AB', ...
Date: 2002-02-20 21:47:09
Message-ID: 200202202147.g1KLl9p13545@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> 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.

In PostgreSQL, you would need to create a column with the CASE, the
order by that using the column number or AS to name the column and order
on that name.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bryan White 2002-02-20 21:54:09 Re: Ordering 'A', 'B', ..., 'Z', 'AA', 'AB', ...
Previous Message Vivek Khera 2002-02-20 21:41:51 Re: [GENERAL] schema error upgrading from 7.1 to 7.2