答案 0 :(得分:1)
这是一种方法:
select count(distinct business_id)
from t
where not exists (select 1
from t t2
where t2.business_id = t.business_id and
t2.status <> 'active'
);
或者,两个聚合级别:
select count(*)
from (select business_id
from t
group by business_id
having min(status) = max(status) and min(status) = 'active'
) b;