SL是主键。 表名 - > IMPO 我想总结所有具有相同型号的QTY。(这里因为INDO666而增加40 + 35)
我试过了:
SELECT i.Model_num, i.QTY
FROM impo AS i
JOIN (SELECT Model_num, SUM(QTY) AS t_qty
FROM impo
GROUP BY Model_num )
AS s ON i.Model_num = s.Model_num
答案 0 :(得分:2)
我不明白为什么你有额外的join
。子查询似乎做你想要的:
SELECT Model_num, SUM(QTY) AS t_qty
FROM impo
GROUP BY Model_num ;