Home  >  Article  >  Database  >  mysql-求一个Mysql语句 查询出当前周的数据按照天分组

mysql-求一个Mysql语句 查询出当前周的数据按照天分组

WBOY
WBOYOriginal
2016-06-06 09:35:441272browse

mysql数据数据库

SELECT
DATE_FORMAT(uploadTime_beg, "%Y-%m-%d") as time,
SUM(field01) as sumStatus1,
SUM(field02) as sumStatus2,
SUM(field03) as sumStatus3,
SUM(field04) as sumStatus4,
SUM(field05) as sumStatus5
FROM
health_realdata
WHERE DATE_FORMAT(uploadTime_beg,'%Y%u') = DATE_FORMAT(CURDATE(),'%Y%u')
GROUP BY DATE_FORMAT(uploadTime_beg,"%Y-%m-%d");

<code>    这个SQL查出的数据如下:    ![图片说明](http://img.ask.csdn.net/upload/201511/24/1448359276_377950.png)    我想要的效果是:虽然数据库中没有2015-11-25的数据,但是也要查出来,只是后面的值显示为0.    请问在MYSQL中如何实现,上面的SQL如何修改呢。    我看到网上说需要一个日历辅助表,说的不是很详细,我试了一下好像有问题,如果这种方法可行,还请大牛们写详细点,谢谢。</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn