select ct.pay_ability,
CONCAT(ROUND(COUNT(
CASE
WHEN lt.overdue_days is not null THEN 1
END
)*100/COUNT(lt.customer_id),1),'%') as overdue_ratio
from customer_tb ct
join loan_tb lt
on lt.customer_id = ct.customer_id
group by pay_ability
order by overdue_ratio desc



京公网安备 11010502036488号