select 产品,红色=sum(case when 颜色='红色' then 数量 else 0 end), 蓝色=sum(case when 颜色='蓝色' then 数量 else 0 end) from test group by 产品