SELECT
t.stime ,CASE WHEN ISNULL(u.forum_count) THEN '0' ELSE u.forum_count END AS count
FROM (
SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY) AS stime
UNION SELECT DATE_SUB(CURDATE(), INTERVAL 2 DAY) AS stime
UNION SELECT DATE_SUB(CURDATE(), INTERVAL 3 DAY) AS stime
UNION SELECT DATE_SUB(CURDATE(), INTERVAL 4 DAY) AS stime
UNION SELECT DATE_SUB(CURDATE(), INTERVAL 5 DAY) AS stime
UNION SELECT DATE_SUB(CURDATE(), INTERVAL 6 DAY) AS stime
UNION SELECT DATE_SUB(CURDATE(), INTERVAL 7 DAY)AS stime
) t
LEFT JOIN cms_user_active_statistics u
ON CAST(u.statistics_time AS DATE) <= t.stime
GROUP BY t.stime
ORDER BY t.stime asc