网站转app工具,想要做网站,文化网站设计经典案例,做网站的大创结项因为业务需求#xff0c;要统计每天的新增用户并且要用折线图的方式展示。如果其中有一天没有新增用户的话#xff0c;这一天就是空缺的#xff0c;在绘制折线图的时候是不允许的#xff0c;所有要求把没有数据的日期也要在图表显示。查询2019-01-10------2019-01-20日的新…因为业务需求要统计每天的新增用户并且要用折线图的方式展示。如果其中有一天没有新增用户的话这一天就是空缺的在绘制折线图的时候是不允许的所有要求把没有数据的日期也要在图表显示。查询2019-01-10------2019-01-20日的新增用户 查询出来是这样的。。。。。。完全不可以绘制图表因为绘制图表要的是这样的数据所以写了以下sql生成绘制图表的数据。帮助有需要的人---------------------------------------------------------------------------------------------------------------------------------------------------------select sum(count) as count, regeistDates from (select count(*) count, date_format(regeistDate,‘%Y-%m-%d‘) regeistDates from t_account awhere a.regeistDate‘2018-12-21 00:00:00‘ and a.regeistDate‘2019-01-21 23:00:00‘GROUP BY regeistDatesUNION ALLselect uu:0 as count,regeistDates from (select num:num1 as number,date_format(adddate(‘2018-12-21 00:00:00‘, INTERVAL num DAY),‘%Y-%m-%d‘) as regeistDatesfrom t_account a ,(select num:-1) twhere adddate(‘2018-12-21 00:00:00‘, INTERVAL num DAY) date_format(‘2019-01-21 23:00:00‘,‘%Y-%m-%d‘)order by regeistDates ) rr) sss GROUP BY sss.regeistDates ORDER BY regeistDates---------------------------------------------------------------------------------------------------------------------------------------------------------sql 的唯一的缺点是日期的排列是按照 t_account 这张表的行数计算的注t_account 为你的数据中的一张表select num:num1 as number,date_format(adddate(‘2018-12-21 00:00:00‘, INTERVAL num DAY),‘%Y-%m-%d‘) as regeistDatesfrom t_account a ,(select num:-1) t以上这个sql 是重点以上只是个人见解如果您有好的方法可以在此文章下进行评论-------------------------------------------------------感谢帮忙的老王 。。。。。。哈哈哈