当前位置: 代码迷 >> Sql Server >> 数据查询排序有关问题
  详细解决方案

数据查询排序有关问题

热度:98   发布时间:2016-04-27 15:28:52.0
数据查询排序问题
请问一个语句,
select [Industryname] as 行业名称, sum([allpile]) as 余额 FROM t_loanexpand where Industryname in('煤炭行业','焦炭行业','钢铁行业','电解行业','水泥行业','其他',
'所有行业') group by [Industryname]

如何可以实现查询出来的列表,"其他"和"所有行业"总在最后.

------解决方案--------------------
SQL code
select    [Industryname] as 行业名称,    sum([allpile]) as 余额FROM t_loanexpand    where Industryname in('煤炭行业','焦炭行业','钢铁行业','电解行业','水泥行业','其他','所有行业')     group by [Industryname]    order by charindex(Industryname,'其他所有行业')
  相关解决方案