/*方式1在sql的数据集里面转换成多列*/
select
sum(case when 名称='苹果' then 数量 else 0 end) as 苹果数量,
sum(case when 名称='香蕉' then 数量 else 0 end) as 香蕉数量,
sum(case when 名称='梨子' then 数量 else 0 end) as 梨子数量
from 表名称
/*方式2*/
使用帆软的横向扩展功能,将名称放在单元格。设置横向扩展。然后数量 放在它的下面。设置数量字段为求和
select sum(b.数量) num from A a
left join b b on a.id_1=b.id_1
group by a.名称