【发布时间】:2019-07-11 07:50:41
【问题描述】:
【问题讨论】:
标签: sql
【问题讨论】:
标签: sql
这是一种方法:
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;
【讨论】: