[thelist] SQL ORDER BY

Matt Warden mwarden at gmail.com
Thu Apr 20 13:16:27 CDT 2006


On 4/20/06, j s <jslist at sbcglobal.net> wrote:
> Hi,
>
> In asp when you do a Select statement - is there anyway to have it ORDER BY specific words in a column?
> 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?
>

select ..
from ...
where ...
order by lower(class) desc, suspended asc

you want class ordered descending in order to get those with "open" to
come before "closed". The lower() is in case there are some
inconsistencies in the case of class (e.g. "Open" vs. "open"), which
will affect the ordering.

--
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