INSERT INTO score_1a (red, blue, purple, green, yellow, cyan)
VALUES (sum(red), sum(blue), sum(purple), sum(green), sum(yellow), sum(cyan) )
这会出现以下错误:
无效使用群组功能。
我该如何解决这个问题?
答案 0 :(得分:0)
我想这会有所帮助
INSERT INTO score_1a (red, blue, purple, green, yellow, cyan)
select sum(red), sum(blue), sum(purple), sum(green), sum(yellow), sum(cyan)
from Score_1a -- Use other table name if u need from other table
答案 1 :(得分:0)
您必须提供SUM
的来源,其中一种方法是使用SELECT
语句
INSERT INTO score_1a (red, blue, purple, green, yellow, cyan)
SELECT
SUM(red), SUM(blue), SUM(purple), SUM(green), SUM(yellow), SUM(cyan)
FROM
tbl2
答案 2 :(得分:0)
INSERT INTO `score_1a` (`red`,`blue`, `purple`, `green`,`yellow`, `cyan`) ( SELECT SUM(red), SUM(blue), SUM(purple), SUM(green), SUM(yellow), SUM(cyan) FROM score_1a );