Re: ORDER BY 'DK', 'DE', DESC? - Mailing list pgsql-general

From Greg Stark
Subject Re: ORDER BY 'DK', 'DE', DESC?
Date
Msg-id 8765aqsqaf.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: ORDER BY 'DK', 'DE', DESC?  (Adam Ruth <aruth@intercation.com>)
List pgsql-general
Adam Ruth <aruth@intercation.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

pgsql-general by date:

Previous
From: jseymour@LinxNet.com (Jim Seymour)
Date:
Subject: Re: Problem converting interval to seconds
Next
From: Thomas Beutin
Date:
Subject: Re: problem with sorting using 'ORDER BY' when character field is filled with numerical values