题解 | #分析客户逾期情况#

分析客户逾期情况

https://www.nowcoder.com/practice/22633632da344e2492973ecf555e10c9

with t1 as
(select pay_ability,count(customer_id) as all_user_cnt from customer_tb
group by pay_ability)

,t2 as
(select a.pay_ability,a.customer_id,b.overdue_days 
from customer_tb a join loan_tb b
on a.customer_id=b.customer_id)

,t3 as
(select t2.pay_ability,count(customer_id) as overdue_user_cnt
from t2
where t2.overdue_days is not null
group by pay_ability)

select 
    t1.pay_ability, 
    coalesce(concat(round(t3.overdue_user_cnt/t1.all_user_cnt*100,1),'%'),'0.0%') as overdue_ratio
from t1 left join t3
on t1.pay_ability=t3.pay_ability
where t1.all_user_cnt <>0
order by overdue_ratio desc

我的难点在于转换成百分比,以及空值转成0.0%。一个错在round位置放错了,第二个错在0.0%没有加引号

全部评论

相关推荐

点赞 评论 收藏
分享
认真搞学习:28小登的建议,投算法岗不要写什么物理竞赛,互联网+,多写点项目,用什么算法做了什么。还有本科算法是不可能的开发你这个也没有项目啊
点赞 评论 收藏
分享
07-09 12:12
门头沟学院 Java
5月底投简历7月初开奖收获秋招第一个offer,虽然白菜价,但至少能保底了
土木转行ing:土木博士想转图像,最后拿了 tp 提前批 sp 最低档,感觉性价比不高
TP-LINK开奖132人在聊
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务