数据统计脚本(汇总)

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

select count(*) from  agentCore.custInfo where channelid=393 and datediff(registertime,'2018-07-22')<=0; #贷款平台
select count(*) from  agentCore.loanCase where channelid=393 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-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-22')<=0
) t where submitstatus=1;

4. 电核数据

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

6. 查看三个平台放款通过与没通过的名单

select
a.channelid, 
date(a.createtime) createtime,
a.id,
a.brwid,
a.brwtelenc,
a.brwidcardcodeenc,
a.brwidcardnameenc,
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 in (393,393,397);

猜你喜欢

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