为什么此代码有效:
SELECT year, sum(value)
FROM test
GROUP BY year
这不是吗?
SELECT year, sum(value)
FROM test
GROUP BY year
WHERE `user` = 1
为什么此代码有效:
SELECT year, sum(value)
FROM test
GROUP BY year
这不是吗?
SELECT year, sum(value)
FROM test
GROUP BY year
WHERE `user` = 1
GROUP BY
需要紧随其后WHERE
:
SELECT year, sum(value) FROM test WHERE user = 1 GROUP BY year
你有没有尝试过
SELECT year, sum(value) FROM test WHERE user = 1 GROUP BY year
?
我不是专家,但请尝试“HAVING”子句:
SELECT year, sum(value)
FROM test
GROUP BY year
having `user` = 1
反转GROUP BY
和WHERE
子句:
SELECT year, SUM(value)
FROM test
WHERE user = 1
GROUP BY year