日期:2014-05-17 浏览次数:20476 次
select sum(case when A=1 then 1 else 0 end)+
sum(case when B=1 then 1 else 0 end)+
sum(case when C=1 then 1 else 0 end)+
sum(case when D=1 then 1 else 0 end) as [1的次数]
from tb
select count(*) from
(select * from TB where A=1
union all
select * from TB where B=1
union all
select * from TB where C=1
union all
select * from TB where D=1
) TT