查询7天sql

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
上一篇:request.setCharacterEncoding()对通过method="GET"输入的参数无效


下一篇:IS-IS快速收敛调优配置实例