libruaryFloor price
    Updated 2024-10-04
    WITH WeeklySales AS (
    SELECT
    block_timestamp,
    nft_id,
    price AS sale_price
    FROM
    flow.nft.ez_nft_sales
    WHERE
    nft_collection = 'A.0b2a3299cc857e29.TopShot' -- Only include TopShot NFT sales
    AND price <= 20.0 -- Only include sales of $20 or less
    AND tx_succeeded = TRUE -- Only include successful transactions
    )

    -- Ranking sales per week and excluding the bottom 2%
    , RankedSales AS (
    SELECT
    block_timestamp,
    nft_id,
    sale_price,
    PERCENT_RANK() OVER (PARTITION BY DATE_TRUNC('week', block_timestamp) ORDER BY sale_price ASC) AS price_rank
    FROM
    WeeklySales
    )

    -- Exclude bottom 2% of sales and find the floor price
    , FilteredSales AS (
    SELECT
    block_timestamp,
    sale_price
    FROM
    RankedSales
    WHERE
    price_rank > 0.02 -- Exclude the lowest 2% of sales (outliers)
    )

    -- Select the weekly floor price
    QueryRunArchived: QueryRun has been archived