[thelist] SQL ORDER BY

Matt Warden mwarden at gmail.com
Thu Apr 20 14:15:43 CDT 2006


On 4/20/06, Matt Warden <mwarden at gmail.com> wrote:
> > In the class column it says Open or Close or Suspended.  With a Select statement can I tell it to ORDER BY Class  - Open then Close then Suspended?

Pardon, I misread the problem.

select *
from ...
where ...
order by case class
        when 'Open' then 1
        when 'Closed' then 2
        when 'Suspended' then 3
    end;

--
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.



More information about the thelist mailing list