问题
I was wondering how to sum and group values using MySQL. Now thats simple, however I have a bit of an odd situation.
I have a table that allows users to insert the amount of cigaretes smoked every day, what I am trying to do is sum the data for every day .
Anybody has any ideas how with php or mysql I could sum the data of cigaretes smoked per day and group it by day ?
回答1:
SELECT
SUM(how_many) AS per_day,
`date`
FROM
cigaretes
GROUP BY
DATE(`date`)
来源:https://stackoverflow.com/questions/9680920/how-to-sum-and-group-values-using-mysql