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
Hi ,
It is basic Concept inside Group By here is your code
SELECT id,Sum(amount)FROM mytable Group By amount

Comments

Popular posts from this blog

Secure Database Connectivity in node.js with mysql

Export data from mysql db to csv file using java

API (Application Programming Interface)