GZselect count(aid) as 合计1,cont(bid) as 合计2,
sum(case when casetype='杀人' then 1 else 0 end) as 杀人
from
(select distinct a.id as aid,b.id as bid,a.案别 as casetype
from table1 a inner join table2 b on a.id=b.id
) s
sum(case when casetype='杀人' then 1 else 0 end) as 杀人
from
(select distinct a.id as aid,b.id as bid,a.案别 as casetype
from table1 a inner join table2 b on a.id=b.id
) s
杀人=(select count(*) from table2 where casetype='杀人' )
from table1 INNER JOIN TABLE2 ON TABLE1.编号 = TABLE2.编号