Ali3NDistribution of Inflow & Outflow To/From CEXs (THORChain)
    Updated 2024-11-07
    select 'Inflow' as type,
    case when rune_amount_usd < 10 then '< $10'
    when rune_amount_usd >= 10 and rune_amount_usd < 100 then '$10 - $100'
    when rune_amount_usd >= 100 and rune_amount_usd < 1000 then '$100 - $1,000'
    when rune_amount_usd >= 1000 and rune_amount_usd < 10000 then '$1,000 - $10,000'
    when rune_amount_usd >= 10000 and rune_amount_usd < 100000 then '$10,000 - $100,000'
    else '> $100,000' end as ttype,
    count (distinct fact_transfers_id) as Transfers
    from thorchain.core.fact_transfers
    where block_timestamp >= '{{From_Date}}' and block_timestamp <= '{{To_Date}}'
    and from_address in (select distinct address from thorchain.core.dim_labels where label_type = 'cex' group by 1)
    group by 1,2

    union all

    select 'Outflow' as type,
    case when rune_amount_usd < 10 then '< $10'
    when rune_amount_usd >= 10 and rune_amount_usd < 100 then '$10 - $100'
    when rune_amount_usd >= 100 and rune_amount_usd < 1000 then '$100 - $1,000'
    when rune_amount_usd >= 1000 and rune_amount_usd < 10000 then '$1,000 - $10,000'
    when rune_amount_usd >= 10000 and rune_amount_usd < 100000 then '$10,000 - $100,000'
    else '> $100,000' end as ttype,
    count (distinct fact_transfers_id) as Transfers
    from thorchain.core.fact_transfers
    where block_timestamp >= '{{From_Date}}' and block_timestamp <= '{{To_Date}}'
    and to_address in (select distinct address from thorchain.core.dim_labels where label_type = 'cex' group by 1)
    group by 1,2

    QueryRunArchived: QueryRun has been archived