这个肯定可以
select A.uid, SUM(CASE WHEN B.id IS NULL THEN 0 ELSE 1 END), A.name, A.age
from A left join B
ON A.uid = B.uid
group by A.uid, A.name, A.age
select v1.uid,isnull(v2.size,0) as size,v1.name,v1.age from 表A v1 left join (select uid,count(*) as size from 表B group by uid) v2 on v1.uid = v2.uid
select * from a left join b on a.uid=b.uid
select a.uid,a.name,a.age,isnull(b.cnt,0) as cnt
from [表A] as a
left join ( select uid,count(1) as cnt from [表B] group by uid ) as b on a.uid = b.uid
select a.uid, min(a.name) name, min(a.age) age, count(b.id) 人数 from a,b where a.uid=b.uid group by b.uid