mysql - Get Sum using php and SQL is date is same -


i have db structure follows:

date         morning    evening qty(ltr)  total  13-may-2015   101         10                111  15-may-2015   10          1.25              11.25    15-may-2015   10          2.25              12.25    15-may-2015   101         10                111  16-may-2015   10          1.25             11.25     16-may-2015   10          2.25             12.25     17-may-2015   10          2.25             12.25     

what want create new table in data same date should in 1 row only, means duplicate dates should added. how can ?

i want result

date         morning    evening qty(ltr)  total  13-may-2015   101         10                111  15-may-2015   121         13.5            134.5 16-may-2015   20          3.5               23.5 17-may-2015   10          2.25             12.25     

you looking group by clause:

select   `date`, sum(morning), sum(evening), sum(total)     mytable group `date` 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -