binhachonUntitled Query
    Updated 2022-05-19
    with aUST_transaction as (
    select
    sender,
    sum(deposit_amount) as deposit_amount
    from flipside_prod_db.anchor.deposits
    where block_id < 7544910
    group by 1
    union all
    select
    sender,
    -sum(amount) as deposit_amount
    from flipside_prod_db.anchor.redeem
    where block_id < 7544910
    group by 1
    ),
    aUST_stats as (
    select
    sender,
    sum(deposit_amount) as deposit_amount
    from aUST_transaction
    group by 1
    ),
    eligible_users as (
    select
    sender,
    case when deposit_amount > 500000 then 500000 else deposit_amount end as corrected_deposit_amount
    from aUST_stats
    where deposit_amount > 0
    )
    select
    sum(corrected_deposit_amount) as total_amount,
    count(*) as number_of_users
    from eligible_users



    Run a query to Download Data