题解 | 分析客户逾期情况
分析客户逾期情况
https://www.nowcoder.com/practice/22633632da344e2492973ecf555e10c9
这里排序应该放在内层,否则会按字典序排序。
select pay_ability, concat(overdue_ratio, "%") as overdue_ratio
from (
select t2.pay_ability,
round(avg(case when t1.overdue_days is not NULL then 1 else 0 end) *100, 1) as overdue_ratio
from loan_tb t1
join customer_tb t2
on t1.customer_id = t2.customer_id
group by t2.pay_ability
order by overdue_ratio desc
) t
