with t1 as ( select ct.pay_ability pay_ability ,count(*) count ,sum(if(lt.overdue_days is not null, 1, 0)) num from loan_tb lt inner join customer_tb ct on lt.customer_id = ct.customer_id group by ct.pay_ability) select pay_ability, concat(round(num / count * 100, 1),'%') overdue_ratio from t1 order by overdue_ratio desc