Ordering by a complex field

From: "Robert James" <srobertjames(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Ordering by a complex field
Date: 2007-07-19 01:12:44
Message-ID: e09785e00707181812l628f1634j163a4190111dc73a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a one varchar field.

I'd like to order so that records where field='2' come first, then '1', then
'9', then anything but '0', then '0'. Is there anyway to do this in a
standard order by clause (that is, without writing a new SQL function)?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Patrick TJ McPhee 2007-07-19 01:25:10 Re: Ordering by a complex field
Previous Message marcelo Cortez 2007-07-19 01:00:45 tsearch2 on postgres8.2.4