你可以这样处理,做成一个查询(空间换取时间)
product_name, goods_idA, sum(number), pdt_descA, storeA
product_name, goods_idA, sum(number), pdt_descB, storeB
product_name, goods_idA, sum(number), pdt_descC, storeC
product_name, goods_idB, sum(number), pdt_descA, storeA
product_name, goods_idB, sum(number), pdt_descB, storeB
product_name, goods_idB, sum(number), pdt_descC, storeC
两个SQL做个连接,剩下的就是输出时去控制成你想要的结构就好了。