maybeyonasmoonbirds_crossover_stats
    Updated 2022-05-03
    with
    to_moonbirds as (
    select
    event_inputs:to::string as user,
    'to' as direction,
    event_inputs:tokenId::string as token_id
    from ethereum_core.fact_event_logs
    where contract_address = '0x23581767a106ae21c074b2276d25e5c3e136a68b'
    and event_name = 'Transfer'
    ),
    from_moonbirds as (
    select
    event_inputs:from::string as user,
    'from' as direction,
    event_inputs:tokenId::string as token_id
    from ethereum_core.fact_event_logs
    where contract_address = '0x23581767a106ae21c074b2276d25e5c3e136a68b'
    and event_name = 'Transfer'
    ),
    moonbird_bals as (
    select
    user,
    sum(
    case when direction='from' then -1
    when direction='to' then 1
    else 0 end
    ) as balances
    from (
    select * from to_moonbirds
    union all
    select * from from_moonbirds
    )
    group by 1
    ),
    total_moonbirds as (
    select
    Run a query to Download Data