按照时间统计各个阶段的数据数量
1.统计每个月卖家的注册数量
2.统计过去12个月的卖家数据
参考:
[url]http://linkyou.blog.51cto.com/1332494/751980/[/url]
1.统计每个月卖家的注册数量
select DATE_FORMAT(create_time,'%Y-%m') as month,count(merchantid) as count
from usr_seller where
merchantid not in (
SELECT t.merchant_id from usr_test_users t WHERE t.merchant_id is not null
) and
DATE_FORMAT(create_time,'%Y')=2016 group by month order by month desc
2.统计过去12个月的卖家数据
select DATE_FORMAT(t.create_time,'%Y-%m') month,count(t.merchantid) as count
from usr_business_info_history t
where merchantid not in (
SELECT t.merchant_id from usr_test_users t WHERE t.merchant_id is not null
) and
DATE_FORMAT(create_time,'%Y-%m')> DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m')
group by month ORDER BY month desc
参考:
[url]http://linkyou.blog.51cto.com/1332494/751980/[/url]