Bala Krishnan Bala Krishnan - 3 months ago 6
MySQL Question

how to sum the value for a selective condition in mysql

my table is

id month amount
1 mar 100
1 apr 100
2 mar 200
2 apr 200
3 mar 300
3 apr 300


I need the out put as

id amount
1 200
2 400
3 600


so pls give the query how to wrrite it

Answer
SELECT id, Sum(amount)FROM mytable Group By amount
Comments