0xbrun0example Holders Of frETH Token copy
    Updated 2023-04-02
    -- forked from 0021ce4e-093d-4be5-8e85-be69f1c5b744
    -- esempio di token holders

    with raw as (
    SELECT
    from_address as address,
    amount* -1 as flow
    FROM ethereum.core.ez_token_transfers
    where contract_address = lower('0xb4bd4628e6efb0cb521d9ec35050c75840320374')

    union all

    select
    to_address as address,
    amount as flow
    FROM ethereum.core.ez_token_transfers
    where contract_address = lower('0xb4bd4628e6efb0cb521d9ec35050c75840320374')

    ),

    pool_holders as (select
    address,
    sum(flow) as holdings
    from raw
    group by address
    having holdings > 0
    ORDER BY HOLDINGS)

    SELECT h.address as holders, holdings, l.label
    FROM pool_holders as h
    LEFT JOIN ethereum.core.dim_labels as l on h.address = l.address
    WHERE h.address not in ('0x573c0609a8cac30b7a8a65e3652f0511caeffd30', '0x6e77889ff348a16547caba3ce011cb120ed73bfc', '0x0fbb8d17027b16810795b12cbeadc65b252530c4', '0x090559d58aab8828c27ee7a7eab18efd5bb90374', '0xc5f0237a2a2bb9dc60da73491ad39a1afc4c8b63', '0x01ff6318440f7d5553a82294d78262d5f5084eff', '0xe8c060f8052e07423f71d445277c61ac5138a2e5', '0xB4Bd4628e6EFb0Cb521D9ec35050C75840320374') and label is NULL
    ORDER BY 2
    DESC


    Run a query to Download Data