with tmp as (select 
t1.customer_id,
t1.pay_ability,
case when overdue_days is null then 0
else 1 end as num,
count(1) over(partition by pay_ability) as total
from customer_tb t1
left join loan_tb t2
on t1.customer_id = t2.customer_id),
tmp2 as (select pay_ability,
sum(num) as num2,
total from tmp group by pay_ability)
select pay_ability,
concat(round(num2/total*100,1),'%') as overdue_ratio
from tmp2 order by overdue_ratio desc