aureasarsanedesaptos in 2024 4
    Updated 44 minutes ago
    WITH nft_data AS (
    SELECT
    DATE_TRUNC('month', block_timestamp) AS month,
    platform_name,
    COUNT(DISTINCT tx_hash) AS total_sales,
    SUM(total_price_usd) AS total_volume_usd
    FROM aptos.nft.ez_nft_sales
    WHERE DATE_TRUNC('day', block_timestamp) BETWEEN '2024-01-01' AND '2024-12-31'
    GROUP BY 1, 2
    ),
    ranked_nft_data AS (
    SELECT
    month,
    platform_name,
    total_sales,
    total_volume_usd,
    RANK() OVER (PARTITION BY month ORDER BY total_volume_usd DESC) AS rank_by_volume
    FROM nft_data
    )
    SELECT
    month,
    platform_name,
    total_sales,
    total_volume_usd
    FROM ranked_nft_data
    WHERE rank_by_volume <= 5
    ORDER BY month DESC, total_volume_usd DESC