码迷,mamicode.com
首页 > 数据库 > 详细

Mysql统计总结 - 最近30天,昨天的数据统计

时间:2015-10-29 16:20:44      阅读:618      评论:0      收藏:0      [点我收藏+]

标签:

-- 最近30天的医说发布数量
SELECT substr(a.feed_publish_time,6, 5) AS ‘日期‘, count(*) AS ‘医说数‘ FROM xm_feed a WHERE
DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= a.feed_publish_time GROUP BY substr(a.feed_publish_time,1, 10);

-- 最近30天的医说评论发布数量
SELECT substr(a.comm_create_time,6, 5) AS ‘日期‘, count(*) AS ‘医说评论数‘ FROM xm_feed_comment a WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= a.comm_create_time GROUP BY substr(a.comm_create_time,1, 10);

-- 最近30天的医说扩散发布数量
SELECT substr(a.repost_create_time,6, 5) AS ‘日期‘, count(*) AS ‘医说评论数‘ FROM xm_feed_repost a WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= a.repost_create_time GROUP BY substr(a.repost_create_time,1, 10);

-- 最近30天的医说点赞发布数量
SELECT substr(a.digg_create_time,6, 5) AS ‘日期‘, count(*) AS ‘医说评论数‘ FROM xm_feed_digg a WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= a.digg_create_time GROUP BY substr(a.digg_create_time,1, 10);

-- 昨天的数据
SELECT count(*) as num FROM xm_user a WHERE a.user_audit_status = ‘AUDITED‘ AND date_sub(current_date(),interval 1 day) = substr(a.user_create_time,1, 10);
SELECT count(*) as num FROM xm_user a WHERE date_sub(current_date(),interval 1 day) = substr(a.user_create_time,1, 10);
SELECT count(*) as num FROM xm_feed a WHERE date_sub(current_date(),interval 1 day) = substr(a.feed_publish_time,1, 10);
SELECT count(*) as num FROM xm_feed_comment a WHERE date_sub(current_date(),interval 1 day) = substr(a.comm_create_time,1, 10);
SELECT count(*) as num FROM xm_feed_repost a WHERE date_sub(current_date(),interval 1 day) = substr(a.repost_create_time,1, 10);
SELECT count(*) as num FROM xm_feed_digg a WHERE date_sub(current_date(),interval 1 day) = substr(a.digg_create_time,1, 10);

Mysql统计总结 - 最近30天,昨天的数据统计

标签:

原文地址:http://www.cnblogs.com/kenshinobiy/p/4920723.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!