views:

14

answers:

2

i friend i have a database table

amount_id, year, amount,

and data like this

1 2002 2
2 2002 3
3 2007 2
4 2004 6
5 2004 10

i wan to run a query to select data like this

2002 4
2007 2
2004 16

thanks for help

A: 

It looks like you need to use a sum(amount) in your select statement and group by year after your where.

Kris.Mitchell
+1  A: 
SELECT `year`, SUM(amount)
FROM databasetable
GROUP BY `year`

Should be all you need.

Marc B