题解 | 分析客户逾期情况
select a.pay_ability, concat (round((sum(判断) / count(*)) * 100, 1), '%') overdue_ratio from ( select case when overdue_days is not null then 1 when overdue_days is null then 0 end 判断, lt.customer_id, customer_age, pay_ability, overdue_days from test.customer_tb ct join test.loan_tb lt on ct.customer_id = lt.customer_id ) a group by a.pay_ability order by overdue_ratio desc