我有2列,像这样:
+----------+--------+ | word | amount | +----------+--------+ | dog | 1 | | dog | 5 | | elephant | 2 | +----------+--------+
我想对金额求和,以获得结果
+----------+--------+ | dog | 6 | | elephant | 2 | +----------+--------+
到目前为止,我已经尝试过(但失败了)的是:
SELECT word, SUM(amount) FROM `Data` Group By 'word'
删除中的单引号WORD。它使列名转换为字符串。
WORD
SELECT word, SUM(amount) FROM Data Group By word