kellenSales Volume by the Top Collection Each Month
    Updated 2023-02-11


    WITH sales AS (
    SELECT INITCAP(l.label) AS collection
    , date_trunc('month', s.block_timestamp) AS month
    , SUM(s.sales_amount) AS volume
    FROM solana.fact_nft_sales s
    JOIN solana.dim_labels l ON l.address = s.mint
    WHERE date_trunc('month', s.block_timestamp) >= '2022-01-01'
    GROUP BY 1, 2
    ), base AS (
    SELECT *
    , ROW_NUMBER() OVER (PARTITION BY month ORDER BY volume DESC) AS rn
    FROM sales
    ), b2 AS (
    SELECT *
    , CONCAT(RIGHT(LEFT(month::varchar, 7), 2), '. ', TO_CHAR(month, 'mon'), ' - ', collection) AS label
    FROM base
    WHERE rn = 1
    )
    SELECT *
    FROM b2
    ORDER BY label

    Run a query to Download Data