How to sum and group values using MySQL ?

ぐ巨炮叔叔 提交于 2019-12-13 09:13:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!