2个回答
2021-09-29
展开全部
MYSQL数据库
SELECT 产品,GROUP_CONCAT(零件),SUM(数量),SUM(金额) FROM (
SELECT 'A' AS 产品,'A1' AS 零件,'10' AS 数量,'10' AS 金额
UNION ALL
SELECT 'A' AS 产品,'A2' AS 零件,'20' AS 数量,'20' AS 金额
UNION ALL
SELECT 'A' AS 产品,'A3' AS 零件,'10' AS 数量,'10' AS 金额
UNION ALL
SELECT 'B' AS 产品,'B1' AS 零件,'10' AS 数量,'10' AS 金额
UNION ALL
SELECT 'B' AS 产品,'B2' AS 零件,'20' AS 数量,'20' AS 金额
UNION ALL
SELECT 'B' AS 产品,'B3' AS 零件,'10' AS 数量,'10' AS 金额
) T GROUP BY 产品
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询