【发布时间】:2020-11-14 13:57:54
【问题描述】:
【问题讨论】:
【问题讨论】:
你想要count(distinct)吗?
select state, count(distinct terrain)
from t
group by state;
【讨论】:
您似乎想要计算具有超过 1 个不同 terrain 的 states 的数量。如果是这样,您可以使用两个级别的聚合:
select count(*) no_mismatches
from (select state from mytable group by state having min(state) <> max(state)) t
【讨论】:
where state = 'North Dakota' 在子查询中吗?