vincent99Q5 Add Paramter to Choose Time Period
    Updated 2023-11-29
    WITH FidenzaSales AS (
    SELECT
    s.TOKENID,
    s.PRICE AS Price_ETH,
    s.PRICE_USD AS Price_USD,
    s.BLOCK_TIMESTAMP,
    m.TOKEN_NAME
    FROM
    ethereum.nft.ez_nft_sales s
    JOIN ethereum.nft.dim_nft_metadata m ON s.TOKENID = m.TOKEN_ID
    WHERE
    m.TOKEN_NAME LIKE '%fidenza%'
    and s.BLOCK_TIMESTAMP BETWEEN '{{DateStart}}'
    AND '{{DateEnd}}'
    ),
    EarliestSales AS (
    SELECT
    TOKENID,
    MIN(BLOCK_TIMESTAMP) AS EarliestSaleTimestamp
    FROM
    FidenzaSales
    GROUP BY
    TOKENID
    ),
    SecondarySales AS (
    SELECT
    fs.TOKENID,
    fs.Price_ETH,
    fs.Price_USD
    FROM
    FidenzaSales fs
    LEFT JOIN EarliestSales es ON fs.TOKENID = es.TOKENID
    WHERE
    fs.BLOCK_TIMESTAMP > es.EarliestSaleTimestamp
    )
    SELECT
    Run a query to Download Data