|
@@ -4,18 +4,23 @@
|
4
|
4
|
|
5
|
5
|
<select id="getNewCustomerSexCount" resultType="com.yunzhi.marketing.statistic.entity.GenderStatistic">
|
6
|
6
|
SELECT
|
7
|
|
- org_id,realty_consultant,
|
8
|
|
- sum(if(sex = 1,1,0)) as man_sum,
|
9
|
|
- sum(if(sex = 1,1,0))/count(*) as man_pct,
|
10
|
|
- sum(if(sex = 2,1,0)) as woman_sum,
|
11
|
|
- sum(if(sex = 2,1,0))/count(*) as woman_pct,
|
12
|
|
- sum(if(sex != 1 and sex != 2,1,0)) as unknown_sum,
|
13
|
|
- sum(if(sex != 1 and sex != 2,1,0))/count(*) as unknown_pct
|
|
7
|
+ t.org_id,
|
|
8
|
+ s.person_id AS realty_consultant,
|
|
9
|
+ sum( IF ( t.sex = 1, 1, 0 ) ) AS man_sum,
|
|
10
|
+ sum( IF ( t.sex = 1, 1, 0 ) ) / count( * ) AS man_pct,
|
|
11
|
+ sum( IF ( t.sex = 2, 1, 0 ) ) AS woman_sum,
|
|
12
|
+ sum( IF ( t.sex = 2, 1, 0 ) ) / count( * ) AS woman_pct,
|
|
13
|
+ sum( IF ( t.sex != 1 AND t.sex != 2, 1, 0 ) ) AS unknown_sum,
|
|
14
|
+ sum( IF ( t.sex != 1 AND t.sex != 2, 1, 0 ) ) / count( * ) AS unknown_pct
|
14
|
15
|
FROM
|
15
|
|
- ta_recommend_customer
|
|
16
|
+ ta_recommend_customer t
|
|
17
|
+ LEFT JOIN ta_person s ON s.person_id = t.realty_consultant
|
|
18
|
+ OR s.user_id = t.realty_consultant
|
16
|
19
|
WHERE
|
17
|
|
- verify_status = 1
|
18
|
|
- GROUP BY org_id,realty_consultant
|
|
20
|
+ t.verify_status = 1
|
|
21
|
+ GROUP BY
|
|
22
|
+ t.org_id,
|
|
23
|
+ s.person_id
|
19
|
24
|
</select>
|
20
|
25
|
<select id="getFollowUpSexCount" resultType="com.yunzhi.marketing.statistic.entity.GenderStatistic">
|
21
|
26
|
SELECT
|
|
@@ -35,7 +40,7 @@
|
35
|
40
|
<select id="getVisiteSexCount" resultType="com.yunzhi.marketing.statistic.entity.GenderStatistic">
|
36
|
41
|
SELECT
|
37
|
42
|
d.org_id,
|
38
|
|
- d.realty_consultant,
|
|
43
|
+ d.realty_consultant_person as realty_consultant,
|
39
|
44
|
sum( IF ( d.sex = 1, 1, 0 ) ) AS manSum,
|
40
|
45
|
sum( IF ( d.sex = 1, 1, 0 ) ) / count( * ) AS manPct,
|
41
|
46
|
sum( IF ( d.sex = 2, 1, 0 ) ) AS womanSum,
|
|
@@ -46,19 +51,22 @@
|
46
|
51
|
(
|
47
|
52
|
SELECT
|
48
|
53
|
t.enlist_id,
|
49
|
|
- c.*
|
|
54
|
+ c.*,
|
|
55
|
+ s.person_id as realty_consultant_person
|
50
|
56
|
FROM
|
51
|
57
|
ta_activity_dynamic_enlist t
|
52
|
58
|
LEFT JOIN ta_recommend_customer c ON t.person_id = c.person_id
|
53
|
|
- AND t.building_id = c.building_id
|
54
|
|
- AND t.org_id = c.org_id
|
55
|
|
- AND c.verify_status = 1
|
|
59
|
+ AND t.building_id = c.building_id
|
|
60
|
+ AND t.org_id = c.org_id
|
|
61
|
+ AND c.verify_status = 1
|
|
62
|
+ LEFT JOIN ta_person s ON s.person_id = c.realty_consultant
|
|
63
|
+ OR s.user_id = c.realty_consultant
|
56
|
64
|
WHERE
|
57
|
65
|
t.is_checkin = 1
|
58
|
66
|
GROUP BY
|
59
|
67
|
c.customer_id
|
60
|
68
|
) d
|
61
|
69
|
GROUP BY
|
62
|
|
- d.org_id,d.realty_consultant
|
|
70
|
+ d.org_id,d.realty_consultant_person
|
63
|
71
|
</select>
|
64
|
72
|
</mapper>
|