boomer77top deposit UST
    Updated 2021-12-20
    with raw as (select msg_value:sender::string as users, count(distinct tx_id) as tx_count, sum(msg_value:coins[0]:amount/1e6) as amount, ROW_NUMBER() OVER (ORDER BY tx_count desc) as rank
    from terra.msgs
    where msg_module = 'wasm'
    and msg_value:contract = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
    and msg_value:coins[0]:denom = 'uusd'
    and msg_value:execute_msg:deposit_stable::string is not null
    and tx_status = 'SUCCEEDED'
    and date(block_timestamp) >= CURRENT_DATE - 30
    group by 1),

    top as (select users, tx_count, amount, 'top_10' as xx
    from raw
    where rank < 11),

    total as (select users, tx_count, amount, 'total' as xx
    from raw
    where users not in (select users from top))

    select xx, sum(amount) as amount from top
    group by 1
    union
    select xx, sum(amount) as amount from total
    group by 1


    Run a query to Download Data