现在的位置: 首页 > 综合 > 正文

SQL Server orderby with some fixed values

2012年03月22日 ⁄ 综合 ⁄ 共 353字 ⁄ 字号 评论关闭

I came across a problem when we want to set the default language to English in a dropdown list. Such as:

Chinese
Danish
English
German
Japanese
Swedish

We want the English come to the first, and the rest follows That’s:

English    //go to first
Chinese
Danish
German
Japanese
Swedish

 

We can do this by uniting the two SQL result sets:

select * from country where lang='English'
union
select * from country where lang<>'English'

抱歉!评论已关闭.