日期:2014-05-18 浏览次数:20502 次
select CarNum, count(CarNum) as [出车次数], count(case shiNW when '市内' then shiNW end) as [市内次数] , count(case shiNW when '市外' then shiNW end) as [市外次数] , sum(Convert(int,Miles)) as [总里程] from qp_CarApply group by CarNum
------解决方案--------------------
select CarNum, count(CarNum) as [出车次数], sum(case shiNW when '市内' then 1 else 0 end) as [市内次数] , sum(case shiNW when '市外' then 1 else 0 end) as [市外次数] , sum(Convert(int,Miles)) as [总里程] from qp_CarApply group by CarNum