题解 | 分析客户逾期情况
分析客户逾期情况
https://www.nowcoder.com/practice/22633632da344e2492973ecf555e10c9
# 判断NULL不能用=,应该用is # round(X,D)表示返回带有D位小数的X # concat(str1, str2, …, strN)用于连接字符串,可以是文本字段、数值字段、表达式或直接的字符串文字。 select pay_ability, concat(round(sum(if(overdue_days is not NULL,1,0))/count(*)*100,1),'%') overdue_ratio from customer_tb a left join loan_tb b on a.customer_id = b.customer_id group by pay_ability order by overdue_ratio desc;
关键在于对函数round和concat的了解。