case when是个好东西

case when是个好东西
在同一个sql语句中写不同条件的Count数量
select sum(case when Experience >= 218706 then 1 else 0 end) as '[25,+',
  sum(case when Experience >= 49065 and Experience < 218706 then 1 else 0 end) as '[20,25)',
       sum(case when Experience >= 11773 and Experience < 49065 then 1 else 0 end) as '[15,20)',
  sum(case when Experience >= 2171 and Experience < 11773 then 1 else 0 end) as '[10,15)'
from QPAccountsDB.dbo.AccountsInfo where IsAndroid = 0;

http://blog.csdn.net/wangziling100/article/details/7598873

你可能感兴趣的:(case when是个好东西)