标签:style blog http color 2014 div log sp on
通过case when 进行自定义排序
select * from (select a.c#,cname,case when score>=85 then ‘100-85‘ when score<85 and score>=70 then ‘85-70‘ when score<70 and score>=60 then ‘70-60‘ else ‘0-60‘ end 段位 ,count(1) 数量 ,count(1)*100.0/(select count(1)from sc where c#=a.c#) 均分 from sc a join course b on a.c#=b.c# group by a.c#,cname,case when score>=85 then ‘100-85‘ when score<85 and score>=70 then ‘85-70‘ when score<70 and score>=60 then ‘70-60‘ else ‘0-60‘ end) a order by a.c#, case 段位 when ‘0-60‘ then 1 when ‘70-60‘ then 2 when ‘85-70‘ then 3 when ‘100-85‘ then 4 end
结果
标签:style blog http color 2014 div log sp on
原文地址:http://www.cnblogs.com/syhsl/p/3936669.html