月份 达标天数 总拜访次数
1月
2月
。。。
。。。
12月
合计
注:一天拜访两个或以上客户为“达标”
传入三个参数:用户ID、起止日期
1月
2月
。。。
。。。
12月
合计
注:一天拜访两个或以上客户为“达标”
传入三个参数:用户ID、起止日期
select DATE_FORMAT(date1,'%Y-%m') as month, sum(case when count1>1 then 1 else 0 end) as times, sum(count1) as total
from
(
select DATE_FORMAT(v_date,'%Y-%m-%d') as date1,count(*) as count1
from p_visit where submit_person = 2 and DATE_FORMAT(v_date,'%Y-%m-%d')>='2009-04-01' and DATE_FORMAT(v_date,'%Y-%m-%d')<='2009-05-31' group by DATE_FORMAT(v_date,'%Y-%m-%d')
) as days
group by month