Updated 2023-09-10

    WITH data AS (
    SELECT
    DATE_TRUNC('week', block_timestamp) AS date,
    count(distinct tx_id) AS sales_count,
    sum(CAST(event_data:salePrice AS DECIMAL(18, 8))) AS sales_volume,
    round(avg(CAST(event_data:salePrice AS DECIMAL(18, 8))), 0) AS avg_NFT_price,
    min(CAST(event_data:salePrice AS DECIMAL(18, 8))) AS floor_price,
    count(distinct event_data:buyer) AS unique_buyers
    FROM
    flow.core.fact_events
    WHERE
    tx_succeeded = true
    AND event_type = 'ListingCompleted'
    AND event_data:nftType = 'A.699bf284101a76f1.JollyJokers.NFT'
    AND event_data:buyer IS NOT NULL
    AND event_data:salePrice IS NOT NULL
    AND event_data:purchased = 'true'
    GROUP BY 1
    )
    SELECT
    date,
    sales_count,
    sum(sales_count) OVER (ORDER BY date) AS total_sales,
    sales_volume,
    sum(sales_volume) OVER (ORDER BY date) AS total_sales_volume,
    avg_NFT_price,
    floor_price,
    unique_buyers
    FROM
    data
    ORDER BY 1 ASC;




    Run a query to Download Data