Sbhn_NPSales Tx, NFTs, Buyers & Sellers Count Over Time
    Updated 2022-10-30
    WITH mint_tx as (
    SELECT
    block_timestamp,
    tx_hash,
    EVENT_INPUTS,
    CONTRACT_ADDRESS,
    EVENT_INPUTS:"_id"::string as token_Id,
    EVENT_INPUTS:"_to"::string as to_address,
    ROW_NUMBER() OVER (PARTITION BY to_address ORDER BY block_timestamp ASC) as rank
    FROM polygon.core.FACT_EVENT_LOGS
    WHERE 1=1
    and event_name = 'TransferSingle'
    and ORIGIN_FUNCTION_SIGNATURE IN ('0x669f5a51', '0x5a86c41a')
    and EVENT_INPUTS:"_from" = '0x0000000000000000000000000000000000000000'
    and TX_STATUS = 'SUCCESS'
    QUALIFY rank = 1 -- Only look at the first mint tx, ignore 2nd onwards
    )
    SELECT
    date_trunc('day', block_timestamp)::date as date,
    COUNT(DISTINCT tx_hash) as Sales_Cnt,
    COUNT(DISTINCT EVENT_INPUTS:"_from") as Sallers_Cnt,
    COUNT(DISTINCT EVENT_INPUTS:"_to") as Buyers_Cnt,
    COUNT(DISTINCT EVENT_INPUTS:"_id") as NFT_Cnt,
    sum(Sales_Cnt) over (order by date) as cum_Sales_Cnt
    FROM polygon.core.FACT_EVENT_LOGS
    WHERE CONTRACT_ADDRESS IN (SELECT CONTRACT_ADDRESS FROM mint_tx)
    and event_name = 'TransferSingle'
    and EVENT_INPUTS:"_from" != '0x0000000000000000000000000000000000000000'
    and TX_STATUS = 'SUCCESS'
    GROUP by 1
    Run a query to Download Data