数据统计脚本(一周)

1. 注册数量;提交借款申请

select count(*) from  agentCore.custInfo where channelid=393 and datediff(registertime,'2018-07-16')>=0 and datediff(registertime,'2018-07-22')<=0; 
select count(*) from  agentCore.loanCase where channelid=393 and datediff(createtime,'2018-07-16')>=0 and datediff(createtime,'2018-07-22')<=0;

2. 填写补充资料人数

select 
count(*) from
(
select 
a.id,
case when b.custid is not null then 1 else 0 end submitstatus
 from agentCore.loanCase a
left join
agentCore.custCompleteInfo b on a.id=b.loancaseid where a.channelid=393 and datediff(a.createtime,'2018-07-16')>=0 and datediff(a.createtime,'2018-07-22')<=0
) t
where submitstatus=1;

3. 工作信息及人行报告

select 
count(institution), # 工作性质
count(incomeMonthly), # 月收入
count(reserveFundTime), # 公积金
count(policyPeriod),  # 保单信息
count(houseProperty), # 房产信息
sum(case when PBCReport=0 then 1 end), #上传人行报告
sum(case when PBCReport=1 then 1 end), # 同意并签署 人行报告
sum(case when PBCReport=2 then 1 end)  # 以后补充人行报告
 from
(
select 
a.id,
a.brwid,
a.brwtelenc,
a.brwidcardcodeenc,
a.brwidcardnameenc,
a.createtime,
a.channelid,
b.custid,
b.loancaseid,
b.idcardnameenc,
b.custtelnoenc,
b.idcardcodeenc,
b.institution,
b.incomeMonthly,
b.reserveFundTime,
b.policyPeriod,
b.premiumYear,
b.houseProperty,
b.houseValuation,
b.repayMonthly,
b.PBCReport,
case when b.custid is not null then 1 else 0 end submitstatus
 from agentCore.loanCase a
left join
agentCore.custCompleteInfo b on a.id=b.loancaseid where a.channelid=393 and datediff(a.createtime,'2018-07-16')>=0 and datediff(a.createtime,'2018-07-22')<=0
) t where submitstatus=1;

4. 电核数据

# {3:通过,4:拒绝,6:跟进,2:审核中}
select 
auditstatus,
count(distinct id) 
from 
agentCore.loanCase where datediff(audittime,'2018-07-22')<=0 and datediff(audittime,'2018-07-16')>=0 group by 1 order by 1;

5. 风控审核数据

#{1000:拒绝,2000:通过}
select 
b.resultcode,
count(distinct caseid) 
from 
agentCore.loanCase a
join
agentCore.loanCaseAutoAuditLog b
on a.id=b.caseid
where datediff(b.createtime,'2018-07-22')<=0 and datediff(b.createtime,'2018-07-16')>=0 group by 1 order by 1;

猜你喜欢

转载自blog.csdn.net/datawhale/article/details/81174492
今日推荐