Pmisha-bmlMdxnumber.of.borrow
    Updated 2022-02-22
    with bb as (select
    msg_value:sender as user_address,
    (msg_value:execute_msg:borrow_stable:borrow_amount) / 1e6 as borrow_amount_UST
    from terra.msgs
    where msg_value:contract = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
    and msg_value:execute_msg:borrow_stable is not NULL
    and tx_status = 'SUCCEEDED'
    and block_timestamp >= CURRENT_DATE - 90
    group by 1,2
    order by 2 DESC)

    select
    user_address,
    count (user_address) as borrow_times,
    sum(borrow_amount_UST) as borrowed_amount
    from bb group by 1 order by 3 desc limit 100
    Run a query to Download Data