select
psperdno "期数",
count(case when psperdno = 1 then (case when date(datadate)-psduedt > 0 then a.custid end) else (case when date(datadate)-psduedt > 15 then a.custid end) end) "总人数",
count(case when latedays > 0 and date(datadate)-psduedt > 0 then a.custid end) "d0逾期人数",
count(case when latedays > 0 and date(datadate)-psduedt > 0 then a.custid end)*1.0/count(case when psperdno = 1 then (case when date(datadate)-psduedt > 0 then a.custid end) else (case when date(datadate)-psduedt > 15 then a.custid end) end) "d0逾期率",
count(case when latedays > 15 and date(datadate)-psduedt > 15 then a.custid end) "d15逾期人数",
count(case when latedays > 15 and date(datadate)-psduedt > 15 then a.custid end)*1.0/count(case when psperdno = 1 then (case when date(datadate)-psduedt > 0 then a.custid end) else (case when date(datadate)-psduedt > 15 then a.custid end) end) "d15逾期率"
from
transformdata.xsfinrank a
join
ylhx4.cxh_xinyanfeature b
on a.custid=b.custid where brrank = 1 and psperdno in (1,2) group by 1;
SQL_Case When 嵌套
最新推荐文章于 2025-01-03 18:50:42 发布
2863

被折叠的 条评论
为什么被折叠?



