sum(case when B.value2 is null then A.value1
else (A.value1+B.value2*C.RATE)*1000 end) as VALUE
ifnull(b.value2,0) 把空值处理成0。
应该是在最里面的SELECT 里用case 外面不用,否则group by 里面需要添加sum的两个字段