From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | pgman(at)candle(dot)pha(dot)pa(dot)us |
Cc: | Charles Albrecht <charlesa(at)pobox(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Ordering 'A', 'B', ..., 'Z', 'AA', 'AB', ... |
Date: | 2002-02-25 20:09:35 |
Message-ID: | 200202252009.g1PK9ZX07998@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
pgman wrote:
> > 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.
Sorry, I was wrong. You can use CASE in ORDER BY. I made a mistake in
my quick testing.
--
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
From | Date | Subject | |
---|---|---|---|
Next Message | Gavin M. Roy | 2002-02-25 20:16:21 | Re: Backup & Restore |
Previous Message | Bruce Momjian | 2002-02-25 20:03:42 | Re: [SQL] Sort problem |