开发者

Group by day even if data is missing

开发者 https://www.devze.com 2023-03-30 19:50 出处:网络
I want to group results by day: max value for each of the the last 30 days. I came up with : select max(value), DATE(time) from table where time>DATE(\'now\', \'-30 days\') group by DATE(time);

I want to group results by day: max value for each of the the last 30 days. I came up with :

select max(value), DATE(time) from table where time>DATE('now', '-30 days') group by DATE(time);

But this on开发者_如何转开发ly gives results for dates with data. I want null or 0 for the dates without data. Is that possible?

0

精彩评论

暂无评论...
验证码 换一张
取 消