当前位置:网站首页>True MySQL interview question (21) - Finance - overdue loan

True MySQL interview question (21) - Finance - overdue loan

2022-06-23 05:48:00 Socialphobia_ FOGO

The loan is overdue

A financial loan company , You need to know about the overdue loans of users . There is a user in the company's database " Loan overdue days " surface .
 Insert picture description here
When overdue days =0 when , Write it down as M0,

Overdue days in [1,30] In the interval , Write it down as M1,

Overdue days in [31,60] In the interval , Write it down as M2,

Overdue days in [61,90] In the interval , Write it down as M3,

Other higher overdue days are recorded as M4+,

Now we need to analyze each overdue period in the database (M0、M1、M2、M3、M4+) Number of orders , If it's you , How will it be analyzed ?

give the result as follows :
 Insert picture description here

SELECT 
SUM(CASE WHEN  Days overdue =0 THEN 1 ELSE 0 END) AS M0,
SUM(CASE WHEN  Days overdue  BETWEEN 1 AND 30 THEN 1 ELSE 0 END) AS M1,
SUM(CASE WHEN  Days overdue  BETWEEN 31 AND 60 THEN 1 ELSE 0 END) AS M2,
SUM(CASE WHEN  Days overdue  BETWEEN 61 AND 90 THEN 1 ELSE 0 END) AS M3,
SUM(CASE WHEN  Days overdue >90 THEN 1 ELSE 0 END) AS M4
FROM  Loan overdue days 
原网站

版权声明
本文为[Socialphobia_ FOGO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206230355227362.html