cloudr3nChad Doge Top Holder List
    Updated 2023-04-13
    with mint as (
    select block_timestamp,
    origin_from_address as address,
    event_inputs:tokenId::INTEGER as tokenId
    from avalanche.core.fact_event_logs
    where event_name='Transfer' and contract_address='0x357928b721890ed007142e45502a323827caf812' and event_inputs:from='0x0000000000000000000000000000000000000000' --and event_inputs:tokenId::INTEGER >=250
    ),
    transfer as (
    select block_timestamp, event_inputs:to as address, event_inputs:tokenId::INTEGER as tokenId
    from avalanche.core.fact_event_logs
    where event_name='Transfer' and contract_address='0x357928b721890ed007142e45502a323827caf812' and event_inputs:from not in ('0x0000000000000000000000000000000000000000') and event_inputs:to not in ('0xc28f1550160478a7fb3b085f25d4b179e08e649a')
    ),
    combine as (
    select * from mint
    union ALL
    select * from transfer
    ),
    max_time as (
    select
    max(block_timestamp) as latest_time,
    /*
    case when max(block_timestamp)=to_timestamp_ntz('2022-07-08 18:47:54.000') and tokenId=2329 then '2022-07-08 18:47:55.000'
    else max(block_timestamp) end as latest_time,*/
    tokenId
    from combine
    group by tokenId
    ),
    current_holders as(
    select DISTINCT
    a.latest_time,
    b.tokenId,
    b.address
    from combine b, max_time a
    where a.latest_time=b.block_timestamp and a.tokenId=b.tokenId
    ),
    Run a query to Download Data