说明:一下是自定义7天为一个时间段的分组统计
select datediff(ms_time, '开始时间') div 7 as time , count(*) count,sum(money) money
from merchant_statistics
WHERE ms_time BETWEEN '2019-02-02' and '2019-03-02'
group by (datediff(ms_time, '开始时间') div 7)