feyikemiCQ - Query 1: Daily token holders for x token copy
    Updated 2024-02-28
    -- forked from sam / CQ - Query 1: Daily token holders for x token @ https://flipsidecrypto.xyz/sam/q/Z2d7K2q-v1pu/cq---query-1-daily-token-holders-for-x-token

    -- we'll be using the Lido token (0x5a98fcbea516cf06857215779fd812ca3bef1b32)
    -- and a timeframe from June 2023

    with min_date as (
    select
    min(block_timestamp)::date as min_timestamp
    from ethereum.core.ez_token_transfers
    where contract_address = '0x5a98fcbea516cf06857215779fd812ca3bef1b32'
    ),

    dates as ( -- my favourite table ; gets a list of dates
    select
    date_day
    from ethereum.core.dim_dates
    where date_day between (select min_timestamp from min_date) and current_date()
    ),

    lido_total_holders as ( -- all possible addresses that have held lido
    select
    distinct to_address
    from ethereum.core.ez_token_transfers
    where contract_address = '0x5a98fcbea516cf06857215779fd812ca3bef1b32' -- lido token
    ),

    dates_x_lido_total_holders as (-- cross join between dates and holders so that for every date, there is an entry for each user
    select
    date_day as full_dates,
    to_address as full_user_addresses
    from dates
    cross join lido_total_holders
    ),

    end_of_day_balance as (
    select
    QueryRunArchived: QueryRun has been archived