简体   繁体   中英

COUNT Data from the past 7 days, but have it so it shows the result for each day in those 7 days

I don't really know how to explain it, but I have a Morris.JS chart in my Web appliication and I want to have the ability to get data from the last 7 days and put it into the chart.

I don't know if using DATE formats work in a Query nor do I know how to do it, so I'm here asking for assistance on it.

My columns are x as the value and datetime as the datetime and I don't know how I would get the value of X for each day for 7 days.

Hopefully this makes sense?

选择,添加日期,按日期分组。

 SELECT DATE(DATE_ADD(my_date, - INTERVAL 7 DAY)), my_data, other_data from TABLE_NAMER group by  DATE(DATE_ADD(my_date, - INTERVAL 7 DAY))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM