-2

I have a mysql table where i may put multiple entries for the same date.

Does anyone know a query which will go through the data and add values up if they land on the same date?

for e.g. 2015-10-01 will have one line with Value1 having the answer of 3

id  date         Value1  Value2  Value3
1   2015-10-01   1       1       1     
2   2015-10-01   2       2       2       
3   2015-10-02   1       1       1       
4   2015-10-02   2       2       2       
5   2015-10-03   1       1       1       
6   2015-10-03   2       2       2       
7   2015-10-03   3       3       3       
Darbs
  • 3
  • 3

1 Answers1

0

You need group by and sum():

select date, sum(value1) as total from table group by date

Shadow
  • 33,525
  • 10
  • 51
  • 64