select b, c, count(*) from a_b_c
group by b, c
having count(distinct b > 1)
or count(distinct...这个错误很容易被忽略,事实上等效于
select b, c, count(*) from a_b_c
group by b, c
having count(1)
or count(1);...你要的是
select b, c, count(*) from a_b_c
group by b, c
having count(distinct b) > 1
or count(distinct...而且最令人沮丧的是,对于某些情况,这种语句是有效的,如果错误地以为就是这么写法,然而对于另外的情况,很可能得到错误结果。
事实上,单纯用GROUP BY 是不可行的。为什么?...from a_b_c group by b having count(*) > 1
union
select c as value, count(*) as cnt, 'c' as what_col