select id, sum(case when dd='1' then 1 else 0 end)as 是1的总数, sum(case when dd<>'1' then 1 else 0 end)as 不是1的总数 from tbname group by id
Select D.id,D.yes,D.no from( SELECT C.id,A.YES,B.NO FROM Table C, (select count(*) as yes from table where id='A00001') A, (select count(*) as no from talble where id<>'A00001') B ) D
select id,sum(case when........end),sum(case when ......end)from table group by id
sum(case when dd='1' then 1 else 0 end)as 是1的总数,
sum(case when dd<>'1' then 1 else 0 end)as 不是1的总数
from tbname
group by id
SELECT C.id,A.YES,B.NO FROM Table C,
(select count(*) as yes from table where id='A00001') A,
(select count(*) as no from talble where id<>'A00001') B
) D