我觉得你先检查一下分组字段有没有null,用null分组可能有交叉的。 另外distinct case when a.flag='1' then case_id end, flag='1'放在where条件里更清晰、更容易找问题。
分组后是不能相等的,是我自己搞晕了自己来解释一下吧 例如: dimCol caseId A 1001 B 1001如果用“select distinct caseId from table”,那结果肯定是 1但如果用“select sum(sums) from (select count(distinct) from table group by dimCol)”,这样的话就是 2了,是我自己搞晕了
另外distinct case when a.flag='1' then case_id end,
flag='1'放在where条件里更清晰、更容易找问题。
例如: dimCol caseId
A 1001
B 1001如果用“select distinct caseId from table”,那结果肯定是 1但如果用“select sum(sums) from (select count(distinct) from table group by dimCol)”,这样的话就是 2了,是我自己搞晕了