Re: ORDER BY 'DK', 'DE', DESC?

From: Greg Stark <gsstark(at)mit(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: ORDER BY 'DK', 'DE', DESC?
Date: 2004-05-20 22:10:48
Message-ID: 8765aqsqaf.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Adam Ruth <aruth(at)intercation(dot)com> writes:

> Due to the sorting of boolean values, you'd need:
>
> ORDER BY language = 'DK' desc, language like '%DE' desc, language;

Personally I find something like this clearer:

ORDER BY (CASE WHEN language = 'DK' THEN 1
WHEN language like '%DE' THEN 2
WHEN ...
ELSE 5
END
)

--
greg

In response to

Browse pgsql-general by date

  From Date Subject
Next Message In. Martin Prášek 2004-05-20 22:11:18 Unix timestamp , unix timestamp with microseconds
Previous Message Jim Seymour 2004-05-20 21:49:09 Re: Problem converting interval to seconds