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

From Bruce Momjian
Subject Re: Ordering 'A', 'B', ..., 'Z', 'AA', 'AB', ...
Date
Msg-id 200202252009.g1PK9ZX07998@candle.pha.pa.us
Whole thread Raw
In response to Ordering 'A', 'B', ..., 'Z', 'AA', 'AB', ...  (Jon Lapham <lapham@extracta.com.br>)
List 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@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [SQL] Sort problem
Next
From: "Gavin M. Roy"
Date:
Subject: Re: Backup & Restore