create table tb(name int, state int, value int)
insert into tb values(1, 1 , 100 )
insert into tb values(2, 2 , 200 )
insert into tb values(1, 1 , 80 )
insert into tb values(2, 2 , 300 )
go
select name , cnt1 = count(*) , cnt2 = (select count(*) from tb where value > 100 and name = a.name) from tb a group by name
drop table tb
/*
name cnt1 cnt2
----------- ----------- -----------
1 2 0
2 2 2
(所影响的行数为 2 行)
*/