SELECT sum((case WHEN sfa28<>0 THEN sfa06/sfa28 else 0 end )*tc_ecr07) as goods_rate ,ta_sfa01,ta_sfa02
FROM sfa_file
JOIN sfb_file ON (sfb01=sfa01)
LEFT JOIN tc_ecr_file ON (tc_ecr01=sfb05 and tc_ecr02=sfb06 and ta_sfa01=tc_ecr03 and ta_sfa02=tc_ecr04)
where sfa01='5101-081200088' GROUP BY sfa01,ta_sfa01,ta_sfa02 ;