SELECT *
  FROM REWARD_GAINERS
   FOR UPDATE;

SELECT B.REWARD_NAME,
       A.*
  FROM REWARD_GAINERS  A,
       REWARD_PROJECTS B
 WHERE A.REWARD_INDEX = B.REWARD_INDEX;

--坐席工号
SELECT DISTINCT S.SALER_CODE,
                S.SALER_NAME,
                T.TEAM_CODE,
                T.TEAM,
                BM.DEPARTMENT_CODE,
                BM.DEPARTMENT_NAME
  FROM TELE_SALER      S,
       TELE_SALER_TEAM T,
       IDST0.BM_T      BM
 WHERE S.TEAM_CODE = T.TEAM_CODE
   AND T.DEPARTMENT_CODE = BM.DEPARTMENT_CODE
   AND S.SALER_CODE = '61136';

SELECT *
  FROM TELE_SALER_TEAM T
 WHERE T.TEAM_CODE = '107077'

    SELECT *
            FROM 坐席车非每日保费
           ORDER BY 坐席名称,
              签单日期;


SELECT 部门,
       SUM(已续保累计) 已续保,
       SUM(到期数) 到期保单,
       ROUND((SUM(已续保累计) / SUM(到期数)) * 100,
             0) || '%' 续保率
  FROM 坐席续保统计
 GROUP BY 部门;

--车非个人每月业绩
SELECT 月份,
       部门代码,
       坐席名称,
       SUM(车险个人客户保费),
       SUM(车非融合保费),
       ROUND(SUM(车非融合保费) / SUM(车险个人客户保费) * 100,
             2) 车非渗透率
  FROM 坐席车非每日保费
 GROUP BY 月份,
          部门代码,
          坐席名称
HAVING 月份 = '10月'
 ORDER BY 部门代码,
          车非渗透率 DESC;

SELECT 坐席名称,
       ROUND(SUM(车非融合保费) / SUM(车险个人客户保费) * 100,
             2) 车非渗透率
  FROM 坐席车非每日保费
 WHERE 部门代码 = 'QDI'
   AND 月份 = '10'
   AND 年份 = '2023'
 GROUP BY 坐席名称
 ORDER BY 车非渗透率 DESC;

--续保率
SELECT 坐席名称,
       ROUND(NVL(SUM(已续保累计) / SUM(到期数) * 100,
                 0),
             2) 续保率
  FROM 坐席续保统计 XB
 WHERE XB.部门 = '续保业务部'
 GROUP BY 坐席名称
 ORDER BY 坐席名称 DESC;
-------------------------------------
SELECT ZX.SALER_NAME,
       BM.DEPARTMENT_NAME
  FROM TELE_SALER      ZX,
       TELE_SALER_TEAM TEAM,
       IDST0.BM_T      BM
 WHERE ZX.SALER_NAME = '张楚沂'
   AND ZX.TEAM_CODE = TEAM.TEAM_CODE
   AND TEAM.DEPARTMENT_CODE = BM.DEPARTMENT_CODE;
----------------------------------------
/*
truncate table BI机构渗透率跟踪表;
*/

SELECT *
  FROM BI电销坐席车非渗透率跟踪表 T
 WHERE T.经办 = '杨苗';

SELECT *
  FROM "BI电销坐席续保率跟踪表-24年"
 WHERE 责任人 = '杨苗';

SELECT *
  FROM BI机构渗透率跟踪表;

SELECT *
  FROM "BI机构续保率跟踪表-24年";
