I need a calculation to count the number of loans from the table below by counting the customer number. If a customer number has one duplicate, then the number of loans is 2. Additionally, I need to count the customers who have changed their loan status from 'Regular' to 'RISK.' We can use id_unique for counting.
date | id_unique | customer_number | loan_status |
|---|
12-05-2023 | 1234512 | 555555 | RISK |
12-05-2023 | 1234513 | 555555 | REGULAR |
12-05-2023 | 4534512 | 444444 | RISK |
12-05-2023 | 8634512 | 666666 | REGULAR |
12-05-2023 | 8634513 | 666666 | RISK |
| | | |
| | | |
13-06-2023 | 1234512 | 555555 | RISK |
13-06-2023 | 4534512 | 444444 | REGULAR |
13-06-2023 | 8634512 | 666666 | REGULAR |
14-06-2023 | 8634513 | 666666 | RISK |
13-06-2023 | 8634512 | 666666 | REGULAR |
| | | |
Desired Output In OAC Tabular column:
No. of loans | Customer Count |
|---|
1 | 1800000 |
2 | 200000 |
3 | 50000 |
4 | 34545 |
5 | 534535 |
6 | 36546 |
7 | 4554 |