日期:2014-05-19  浏览次数:20411 次

select以特定条件排序
select   CompanyName,City     from   ITCompany   order   by   +什么可以让收出来的结果按city=上海,city=杭州,city=深圳这个顺序先排在前面,后面的城市随意排无所谓。
或者其他的尽量简单方便的方法?

------解决方案--------------------
select CompanyName,City, '0 ' from ITCompany Where city = '上海 '
Union
select CompanyName,City, '1 ' from ITCompany Where city = '杭州 '
Union
select CompanyName,City, '2 ' from ITCompany Where city = '深圳 '
Union
select CompanyName,City, '3 ' from ITCompany Where city not in ( '上海 ', '杭州 ', '深圳 ')
Order By Sort