SELECT yy_code AS visit_area, RTRIM
((SELECT description
FROM pls..yingye_base
WHERE yy_code = A.yy_code)) AS 营业所, COUNT(*) AS visit_count,
DATEDIFF(Day, '2007/01/21 ', '2007/02/20 ') + 1 -
(SELECT COUNT(*)
FROM PUNCH..AM13
WHERE riqi > = '2007/01/21 ' AND riqi <= '2007/02/20 ') - 1 AS visit_days,
(SELECT COUNT(*) 'tempcolsaleddd '
FROM (SELECT slsman
FROM crm_visit
WHERE 1 = 1 AND CONVERT(char(10), visit_date, 111) > = '2007/01/21 ' AND
CONVERT(char(10), visit_date, 111) <= '2007/02/20 ' AND
yy_code = A.yy_code AND slsman IN
(SELECT slsman
FROM pls..yingye_slsman
WHERE haspart = 0)
GROUP BY slsman) CCCCDDDDD) AS '业务员数 ',
(SELECT COUNT(*) 'tempcol '
FROM (SELECT yy_code, slsman, visit_date
FROM crm_visit
WHERE 1 = 1 AND CONVERT(char(10), visit_date, 111) > = '2007/01/21 ' AND