theericstoneOn-chain Secondary Sales
    Updated 2023-10-12
    -- initially forked from 0xsalty /
    -- Starbucks: Secondary Sales
    -- @ https://flipsidecrypto.xyz/0xsalty/q/ZdmTI2IBm6V1/starbucks-secondary-sales

    with alltxns as (
    select tx_hash from
    polygon.core.fact_traces trac
    where trac.to_address = lower('0x1ff052df592ffcf42fe6a4173975d351dcc99d45')
    and block_timestamp > '2022-08-01'
    ),

    transfers as (
    SELECT
    *
    FROM
    polygon.core.ez_nft_transfers
    WHERE
    (nft_address = lower('0x1fF052Df592FFCf42Fe6A4173975d351Dcc99d45')
    OR tx_hash IN (select tx_hash from alltxns))
    and block_timestamp > '2022-08-01'
    ),

    sales as (
    SELECT
    *
    FROM
    polygon.nft.ez_nft_sales
    WHERE
    nft_address IN (select distinct nft_address from transfers)
    OR tx_hash IN (select distinct tx_hash from alltxns)
    and block_timestamp > '2022-08-01'
    )
    select * from sales

    SELECT
    date,
    Run a query to Download Data