sepehrmhz82023-06-10 06:09 PM
    Updated 2024-06-08
    select
    date_trunc(month, block_timestamp) as date,
    'Borrow' as
    type,
    count(DISTINCT (tx_hash)) as Txs,
    count(DISTINCT (borrower)) as Users,
    sum(loan_amount_usd) as Volume,
    avg(loan_amount_usd) as avg_volume,
    median(loan_amount_usd) as median_volume,
    max(loan_amount_usd) as max_volume,
    min(loan_amount_usd) as min_volume,
    sum(Txs) over (
    partition by
    type
    order by
    date
    ) as cum_tx,
    sum(Users) over (
    partition by
    type
    order by
    date
    ) as cum_user,
    sum(Volume) over (
    partition by
    type
    order by
    date
    ) as cum_volume
    from
    ethereum.compound.ez_borrows
    where loan_amount_usd is not null
    group by
    1,
    2
    UNION
    QueryRunArchived: QueryRun has been archived