alirsBridger Destinations-part-04
    Updated 2022-08-01
    WITH bridge_txns AS (
    select
    date(block_timestamp) as date,
    block_id,
    tx_id,
    to_address as wallet,
    symbol,
    amount_usd
    from polygon.udm_events
    where amount is not null
    and symbol is not NULL
    and origin_address = '0x0000000000000000000000000000000000000000'
    and amount > 0
    and block_timestamp >='2022-01-01'
    ),
    daily_bridge AS (
    select
    date,
    symbol,
    count(distinct tx_id) as txns,
    count(distinct wallet) as wallets,
    sum(amount_usd) as amount_usd_sum,
    row_number() over(partition by date order by amount_usd_sum desc) as amount_rank,
    case when amount_rank < 5 then symbol else 'rest' end as currency_category
    from bridge_txns
    group by date, symbol
    )
    SELECT
    *
    FROM daily_bridge
    order by date asc , amount_usd_sum desc


    Run a query to Download Data