I have to optimize an old query, which contains a lot of case when conditions in the select and group by. It has just one figure(fact) and rest are dimensions. The optimized version has exactly the same where part, so same filter. Nevertheless when I sum up this one figure for the whole output, just to check both versions, I get slightly higher figure with the old version. How is that possible when the filter is the same? Can the case when conditions in the group by somehow be responsible for double counting? Pls see below examples for both versions:New version:selectcategory,figurefrom AwheresameCondition
Old version:selectmax(category),sum(figure)from AwheresameConditiongroup bycase when1,...case when100000