0-MIDloan holding
Updated 2023-04-13
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
›
⌄
with tab1 as (
select min(BLOCK_TIMESTAMP::date) as loan_time,BORROWER
from ethereum.compound.ez_borrows
group by 2),
tab2 as (
select min(BLOCK_TIMESTAMP::date)as repay_time,PAYER
from ethereum.compound.ez_repayments
group by 2)
select count(PAYER) as payer_count,datediff(day,loan_time,repay_time)as loan_held_time
,case
when loan_held_time>=0 and loan_held_time<10 then '1-10 DAYS'
when loan_held_time>=10 and loan_held_time<30 then '10 DAYS-1 MONTH'
when loan_held_time>=30 and loan_held_time<90 then '1 MONTH-3 MONTHS'
when loan_held_time>=90 and loan_held_time<180 then '3 MONTHS-6 MONTHS'
when loan_held_time>=180 and loan_held_time<270 then '6 MONTHS-9 MONTHS'
when loan_held_time>=270 and loan_held_time<365 then '9 MONTHS-1 YEAR'
when loan_held_time>=365 and loan_held_time<730 then '1 YEAR-2 YEARS'
when loan_held_time>=730 and loan_held_time<1095 then '2 YEARS-3 YEARS'
when loan_held_time>=1095 then 'UP TO 3 YEARS' end as held_period
from tab1
left join tab2
on tab1.BORROWER=tab2.PAYER
where held_period is not null
group by 2
Run a query to Download Data