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
Post a Comment