Sql Postgres中如何分组并返回求和行

Sql Postgres中如何分组并返回求和行,sql,postgresql,aggregate-functions,Sql,Postgresql,Aggregate Functions,我被困在这里了。我在博士后中有这样一行: id amount a 5000 a 1500 a 500 b 2000 b 1000 c 4000 sql语法是如何得到这样的结果的 id amount a 7000 b 3000 c 4000 SELECT id, SUM(amount) AS amount FROM yourtable GROUP BY id

我被困在这里了。我在博士后中有这样一行:

id      amount
a       5000
a       1500
a       500
b       2000
b       1000
c       4000
sql语法是如何得到这样的结果的

id      amount
a       7000
b       3000
c       4000
SELECT id, SUM(amount) AS amount
FROM yourtable
GROUP BY id