shengyi-chiuUntitled Query
    Updated 2022-07-16
    WITH first_buy_date as (
    select
    min(block_timestamp::date) as first_buy_date_nft,
    tx_id,
    TO_ADDRESS,
    AMOUNT_USD
    from flipside_prod_db.polygon.udm_events --a join ethereum.core.dim_dates b on a.date_trunc('month', block_timestamp) = b.MONTH_START_DATE
    where EVENT_NAME = 'transfer'
    and AMOUNT_USD > 0
    and TO_ADDRESS not in ('0x0000000000000000000000000000000000000000' ,'0x00000000000b69ec332f49b7c4d2b101f93c3bed'
    ,'0x00000000000b69ec332f49b7c4d2b101f93c3bed','0x00000000000b186ebef1ac9a27c7eb16687ac2a9'
    ,'0x000000000000000000000000000000000000dead','0x0000000000000000000000000000000000000001')
    and CONTRACT_ADDRESS in (select address from polygon.core.dim_labels where LABEL_TYPE='nft'
    and label_subtype in ('token_contract', 'general_contract'))
    GROUP by 2,3,4
    )
    ,first_tx_date as (
    select
    min(block_timestamp::date) as first_date_tx,
    from_address
    from flipside_prod_db.polygon.udm_events u
    where from_address not in ('0x0000000000000000000000000000000000000000' ,'0x00000000000b69ec332f49b7c4d2b101f93c3bed'
    ,'0x00000000000b69ec332f49b7c4d2b101f93c3bed','0x00000000000b186ebef1ac9a27c7eb16687ac2a9'
    ,'0x000000000000000000000000000000000000dead','0x0000000000000000000000000000000000000001')
    group by 2
    )
    ,count_start as (
    select
    count(from_address) as first_tx_count
    from first_tx_date a join first_buy_date b
    on (b.TO_ADDRESS = a.from_address and b.first_buy_date_nft = a.first_date_tx)
    )
    ,count_all as (
    select
    count(from_address) as all_user
    from first_tx_date
    Run a query to Download Data