标签:
新人成长跟踪表设计方案
潘强是此需求的BA,座机号码:621595
欧阳恩坤是SAS系统组的开发,此需求在源头系统取数上有任何疑问都可以请教他,座机号码:608142
开发此报表前,请先阅读“前线销售人力表”报表的加工逻辑,附件”前线销售人力表整理.txt“是我整理的,可以参考
维度的设计
统计时间 年、月
机构 区域细分至二三四级机构
渠道 直销/重客/银保/综拓/代理/车行/新渠道
人员类别 VP/VA/M/S
年龄区间 分为25岁以下、25-30岁、30-35岁、35-40岁、40-50岁、50岁以上
学历 高中及以下、大专、本科、研究生及以上
以上六个维度跟“前线销售人力表”报表一样
============================================================================================================
入渠时间(或入司) 进入渠道的时间节点(年,月)(不能大于月末时间点):
包括新入司的员工,和老员工转渠的时间
SELECT ACCURATE_START_DATE
FROM (SELECT CHN.EMPLOYEE_CODE,
CHN.CHANNEL_TYPE,
MIN(CHN.START_DATE) ACCURATE_START_DATE,
MAX(NVL(CHN.END_DATE, DATE ‘2051-01-01‘)) ACCURATE_END_DATE
FROM (SELECT EMP.EMPLOYEE_CODE,
HIS.CHANNEL_TYPE,
HIS.CHANNEL_DUTY,
HIS.START_DATE,
HIS.END_DATE,
ROW_NUMBER() OVER(ORDER BY EMP.EMPLOYEE_CODE, HIS.START_DATE) - ROW_NUMBER() OVER(PARTITION BY EMP.EMPLOYEE_CODE, HIS.CHANNEL_TYPE ORDER BY EMP.EMPLOYEE_CODE, HIS.START_DATE) IND
FROM EPCISBASE.SAS_EMPLOYEE EMP,
EPCISBASE.SAS_LEVEL_HISTORY HIS
WHERE EMP.HR_CODE IS NOT NULL
AND EMP.EMPLOYEE_CODE = HIS.EMPLOYEE_CODE
AND EMP.ENTER_DATE < 结束时间
AND NVL(EMP.LEAVE_DATE, SYSDATE) >= 开始时间
AND EMP.EMPLOYEE_CODE = 业务员编码) CHN
GROUP BY CHN.EMPLOYEE_CODE, CHANNEL_TYPE, IND) TEMP
WHERE TEMP.CHANNEL_TYPE = 渠道编码;
保费区间,也就是上年保费达成60万以下、60-100万、100-150万、150万-200万、200-300万、300万-500万,500万及以上 sql如下============================================================================================================
--2015年以前查法
--epcis_SAS_COLLECT_CHANNEL
SELECT SUM(TT.COLLECT_AMOUNT)
FROM SASMAN.SAS_COLLECT_CHANNEL TT
WHERE TT.EMPLOYEE_CODE = 业务员编码
AND TT.YEAR = 年份
--AND TT.MONTH = 月份;
--2015年之后查法
--?
SELECT t.COLLECT_AMOUNT,t.*
FROM SASMAN.SAP_COLLECT_CHANNEL_EMP_DAILY t--业务员保费按日汇总表
WHERE t.EMPLOYEE_CODE = 业务员代码
AND t.ACCOUNT_DATE >= 起始日期
AND t.ACCOUNT_DATE < 结束日期;
入司人员类型 普通/培养期新人/猎鹰(培养其新人定义:曾有过免考核标识为“应届生”,猎鹰“入司当年的保费计划高于淘汰底线”,其他为普通)========================================================================================================================
培养期新人的判断方法
--epcis_SAS_DISMISS_DEGRADE
SELECT T.EMPLOYEE_CODE
FROM SASMAN.SAS_DISMISS_DEGRADE T
WHERE T.DEGRADE_TYPE = ‘D‘
AND T.BEGIN_DATE <= 开始时间
AND T.END_DATE >=结束时间
AND T.EMPLOYEE_CODE = 业务员编码
AND T.CONFIRM_FLAG=‘1‘
猎鹰的判断方法:猎鹰是指“入司当年的保费计划高于淘汰底线”的业务员
/*淘汰底线*/
--?
--epcis_DEPARTMENT_DEFINE
--EPCIS_SAS_EMPLOYEE
SELECT A.STANDARD_AMOUNT
FROM (SELECT A.STANDARD_AMOUNT
FROM SAS_DIRECT_DEGRADE_SET A,
DEPARTMENT_DEFINE B,
EPCISBASE.SAS_EMPLOYEE E
WHERE A.DEPARTMENT_CODE = B.DEPARTMENT_CODE
AND E.DEPARTMENT_CODE = B.DEPARTMENT_CODE
AND (A.EFFECTIVE_DATE <=
TO_DATE(TRUNC(开始时间, ‘MM‘), ‘yyyy-mm-dd‘) AND
NVL(A.INVALID_DATE, SYSDATE) >
TO_DATE(TRUNC(开始时间, ‘MM‘), ‘yyyy-mm-dd‘) AND
NVL(B.INVALIDATE_DATE, SYSDATE) >=
TO_DATE(TRUNC(开始时间, ‘MM‘), ‘yyyy-mm-dd‘))
AND A.PREMIUM_TYPE = ‘B‘ -- B为实收保费底线, A为标准底线
AND E.EMPLOYEE_CODE = 业务员编码
ORDER BY B.DEPARTMENT_LEVEL DESC) A
WHERE ROWNUM = 1
/*当年保费计划*/
--?
SELECT T.PREMIUM_PLAN
FROM SAP_EMP_PREMIUM_PLAN T
WHERE T.CHANNEL = ‘DS‘ --直销
AND T.EMPLOYEE_CODE = 业务员
AND T.DUTY = 业务员职务
AND T.CHANNEL = 业务员渠道
AND YEAR = 年
AND MONTH IS NULL
AND T.PREMIUM_PLAN_TYPE = ‘ACCUMULATET‘;
UNION ALL
SELECT T.PREMIUM_PLAN
FROM SAP_EMP_PREMIUM_PLAN T
WHERE T.CHANNEL = ‘BS‘ --重点客户
AND T.EMPLOYEE_CODE = 业务员
AND DUTY = 业务员职务
AND T.CHANNEL = 业务员渠道
AND YEAR = 年
AND MONTH IS NULL
AND T.PREMIUM_PLAN_TYPE = ‘ACCUMULATET‘;
UNION ALL
SELECT T.PREMIUM_PLAN
FROM SAP_EMP_PREMIUM_PLAN T
WHERE T.CHANNEL = ‘IS‘ --银保
AND T.EMPLOYEE_CODE = ‘业务员‘
AND T.DUTY = 业务员职务
AND T.CHANNEL = 业务员渠道
AND YEAR = 年
AND MONTH IS NULL
AND T.PREMIUM_PLAN_TYPE = ‘TT‘;
指标的设计
月末在职人力:
和“前线销售人力表”的月末在职人力取法一样
入渠人数:
也就是 当月新入司人员 和 新转入本渠道的老员工 ,他们所入的渠道就是新入渠人数
当月新入司人力和“前线销售人力表”的取法一样
新转入本渠道的老员工逻辑:先判断是否是老员工,再判断此员工的本月渠道与上月渠道是否一样,如果不一样,则是新转入本渠道的人力,
----EPCIS_SAS_EMPLOYEE,EPCIS_SAS_LEVEL_HISTORY
SELECT CHANNEL_TYPE--渠道
FROM (SELECT CHN.EMPLOYEE_CODE,
CHN.CHANNEL_TYPE,
MIN(CHN.START_DATE) ACCURATE_START_DATE,
MAX(NVL(CHN.END_DATE, DATE ‘2051-01-01‘)) ACCURATE_END_DATE
FROM (SELECT EMP.EMPLOYEE_CODE,
HIS.CHANNEL_TYPE,
HIS.CHANNEL_DUTY,
HIS.START_DATE,
HIS.END_DATE,
ROW_NUMBER() OVER(ORDER BY EMP.EMPLOYEE_CODE, HIS.START_DATE) - ROW_NUMBER() OVER(PARTITION BY EMP.EMPLOYEE_CODE, HIS.CHANNEL_TYPE ORDER BY EMP.EMPLOYEE_CODE, HIS.START_DATE) IND
FROM EPCISBASE.SAS_EMPLOYEE EMP,
EPCISBASE.SAS_LEVEL_HISTORY HIS
WHERE EMP.HR_CODE IS NOT NULL
AND EMP.EMPLOYEE_CODE = HIS.EMPLOYEE_CODE
AND EMP.ENTER_DATE < 结束时间
AND NVL(EMP.LEAVE_DATE, SYSDATE) >= 开始时间
AND EMP.EMPLOYEE_CODE = 业务员编码) CHN
GROUP BY CHN.EMPLOYEE_CODE, CHANNEL_TYPE, IND) TEMP
转渠人数:===
这里指的是转出渠道的人数,代码实现自己写:
1.先判断是否离司,取没有离司的数据
2.如果是新员工在月初入了某个渠道,在月末之前又离开了这个渠道,转去其他渠道,则也属于转渠,如果下面同个业务员编码返回两个渠道,则属于此种情况。做法是先判断是否是新员工,如果是新员工,则判断下面是否返回两条记录,如果是是两条则是转渠,否则不是
----EPCIS_SAS_EMPLOYEE,EPCIS_SAS_LEVEL_HISTORY
SELECT CHANNEL_TYPE--渠道
FROM (SELECT CHN.EMPLOYEE_CODE,
CHN.CHANNEL_TYPE,
MIN(CHN.START_DATE) ACCURATE_START_DATE,
MAX(NVL(CHN.END_DATE, DATE ‘2051-01-01‘)) ACCURATE_END_DATE
FROM (SELECT EMP.EMPLOYEE_CODE,
HIS.CHANNEL_TYPE,
HIS.CHANNEL_DUTY,
HIS.START_DATE,
HIS.END_DATE,
ROW_NUMBER() OVER(ORDER BY EMP.EMPLOYEE_CODE, HIS.START_DATE) - ROW_NUMBER() OVER(PARTITION BY EMP.EMPLOYEE_CODE, HIS.CHANNEL_TYPE ORDER BY EMP.EMPLOYEE_CODE, HIS.START_DATE) IND
FROM EPCISBASE.SAS_EMPLOYEE EMP,
EPCISBASE.SAS_LEVEL_HISTORY HIS
WHERE EMP.HR_CODE IS NOT NULL
AND EMP.EMPLOYEE_CODE = HIS.EMPLOYEE_CODE
AND EMP.ENTER_DATE < 结束时间
AND NVL(EMP.LEAVE_DATE, SYSDATE) >= 开始时间
AND EMP.EMPLOYEE_CODE = 业务员编码) CHN
GROUP BY CHN.EMPLOYEE_CODE, CHANNEL_TYPE, IND) TEMP
3.老员工的情况,如果没有离司且不是新员工,则是老员工,先判断是否老员工,然后拿他们月初所在渠道和月末所在渠道对比,不一样则就是转渠的,比如说月初是在代理渠道,现在转到银保渠道,则银保渠道的转渠人数+1,而且他们的EMPLOYEE_CODE要一样,比如现在是7月27日,那这里的月初就是指6月1日0点,月末就是7月1日0点
----EPCIS_SAS_EMPLOYEE,EPCIS_SAS_LEVEL_HISTORY
SELECT CHANNEL_TYPE--上个月渠道
FROM (SELECT CHN.EMPLOYEE_CODE,
CHN.CHANNEL_TYPE,
MIN(CHN.START_DATE) ACCURATE_START_DATE,
MAX(NVL(CHN.END_DATE, DATE ‘2051-01-01‘)) ACCURATE_END_DATE
FROM (SELECT EMP.EMPLOYEE_CODE,
HIS.CHANNEL_TYPE,
HIS.CHANNEL_DUTY,
HIS.START_DATE,
HIS.END_DATE,
ROW_NUMBER() OVER(ORDER BY EMP.EMPLOYEE_CODE, HIS.START_DATE) - ROW_NUMBER() OVER(PARTITION BY EMP.EMPLOYEE_CODE, HIS.CHANNEL_TYPE ORDER BY EMP.EMPLOYEE_CODE, HIS.START_DATE) IND
FROM EPCISBASE.SAS_EMPLOYEE EMP,
EPCISBASE.SAS_LEVEL_HISTORY HIS
WHERE EMP.HR_CODE IS NOT NULL
AND EMP.EMPLOYEE_CODE = HIS.EMPLOYEE_CODE
AND EMP.ENTER_DATE < 结束时间 减 一个月
AND NVL(EMP.LEAVE_DATE, SYSDATE) >= 开始时间 减 一个月
AND EMP.EMPLOYEE_CODE = 业务员编码) CHN
GROUP BY CHN.EMPLOYEE_CODE, CHANNEL_TYPE, IND) TEMP
离司人数:
和“前线销售人力表”的离司人力取法一样
留存率:代码实现自己写
月末在职人数/(入渠时间点的在渠人力数+入渠至月末进入渠道的人力数)
入渠时间点的在渠人力数:就是月初在渠的老员工数量
入渠至月末进入渠道的人力数:就是新进入此渠道的员工数量,包括新入司的和老员工转入此渠道的
在职人员当月保费 :
先判断是否在职,再取当月保费
--2015年以前查法
SELECT SUM(TT.COLLECT_AMOUNT)
FROM SASMAN.SAS_COLLECT_CHANNEL TT
WHERE TT.EMPLOYEE_CODE = 业务员编码
AND TT.YEAR = 年份
AND TT.MONTH = 月份;
--2015年之后查法
SELECT t.COLLECT_AMOUNT,t.*
FROM SASMAN.SAP_COLLECT_CHANNEL_EMP_DAILY t--业务员保费按日汇总表
WHERE t.EMPLOYEE_CODE = 业务员代码
AND t.ACCOUNT_DATE >= 起始日期
AND t.ACCOUNT_DATE < 结束日期;
在职人员年累计保费:
先判断是否在职,再取当年累计保费
--2015年以前查法
SELECT SUM(TT.COLLECT_AMOUNT)
FROM SASMAN.SAS_COLLECT_CHANNEL TT
WHERE TT.EMPLOYEE_CODE = 业务员编码
AND TT.YEAR = 年份
AND TT.MONTH = 月份;
--2015年之后查法
SELECT t.COLLECT_AMOUNT,t.*
FROM SASMAN.SAP_COLLECT_CHANNEL_EMP_DAILY t--业务员保费按日汇总表
WHERE t.EMPLOYEE_CODE = 业务员代码
AND t.ACCOUNT_DATE >= 起始日期
AND t.ACCOUNT_DATE < 结束日期;
在职人员当年承保客户数 : 在职人员当年承保客户数 /对应的在职人力数
在职人员当年承保客户数代码如下:
SELECT
A.SALE_AGENT_CODE, --业务员编码
COUNT(DISTINCT B.CLIENT_NAME) AS CLIENT_NUM --唯一客户数
FROM (SELECT A.POLICY_NO, A.SALE_AGENT_CODE
FROM EPCIS_AUTO_POLICY_BASE_INFO A
WHERE A.POLICY_NO = B.POLICY_NO(+)
AND A.UNDERWRITE_TIME >= TRUNC(开始时间,‘YYYY‘)
AND A.UNDERWRITE_TIME < 结束时间
AND A.BUSINESS_TYPE = ‘2‘
AND A.CANEL_MARK = ‘N‘
UNION ALL
SELECT A.POLICY_NO, A.SALE_AGENT_CODE
FROM EPCIS_NL_POLICY A
WHERE A.POLICY_NO = B.POLICY_NO(+)
AND A.UNDERWRITE_TIME >= TRUNC(开始时间,‘YYYY‘)
AND A.UNDERWRITE_TIME < 结束时间
AND A.BUSINESS_TYPE = ‘2‘
AND A.CANEL_MARK = ‘N‘
UNION ALL
SELECT A.POLICY_NO, A.SALE_AGENT_CODE
FROM EPCIS_ACC_POLICY_BASE_INFO A
WHERE A.POLICY_NO = B.POLICY_NO(+)
AND A.UNDERWRITE_TIME >= TRUNC(开始时间,‘YYYY‘)
AND A.UNDERWRITE_TIME < 结束时间
AND A.BUSINESS_TYPE = ‘2‘
AND A.CANEL_MARK = ‘N‘) A,
EPCIS_ECIF_CLIENT_INFO_APPLY B --团体客户保单信息表
WHERE A.POLICY_NO = B.POLICY_NO(+)
GROUP BY A.SALE_AGENT_CODE
报表初始化数据范围:2013年1月到当前月
该新建oracle 表就建表,该新建job就新建job,一个结果表不能实现就建些中间表
标签:
原文地址:http://www.cnblogs.com/zhangwensi/p/4730708.html