风险统计分析,离不开vintage,滚动率,迁移率,逾期率等指标的统计,贴一段递延率的Mysql代码,仅做参考。
#create view overdue_list2
#as
#逾期(递延)表
SELECT
DATE_FORMAT(a.endtime, '%Y-%m-%d') as '日期',
count(a.apply_id) '销售量#',
sum(if(a.`status` != 2 or a.success_status = 3,1,0)) '首日逾期#',
concat(TRUNCATE(sum(if(a.`status` != 2 or a.success_status = 3,1,0))/count(a.apply_id)*100, 2),'%') '首日逾期率#%',
sum(if(a.`status` != 2,1,0)) '当前逾期#',
concat(TRUNCATE(sum(if(a.`status` != 2,1,0))/count(a.apply_id)*100, 2),'%') '当前逾期率#%',
count(a.apply_id)- sum(if(a.real_endtime is not null and DATEDIFF(a.real_endtime,a.endtime)<=0,1,0)) 'dpd-1',
count(a.apply_id) - sum(if(a.real_endtime is not null and 0
count(a.apply_id) - s