select Fname, sum(case Ftype when 'zaocan' then Fvalue else 0 end) as zaocan_value,sum(case Ftype when 'zhongcan' then Fvalue else 0 end) as zhongcan_value,sum(case Ftype when 'wancan' then Fvalue else 0 end) as wancan_value from case_table group by Fname