elvisNFTX Q1.1 22/6/12 TOTAL VOLUME ON NFTX
    Updated 2022-06-12
    /*
    Q1. Which 3 NFT collections have the most total sales volume in the last 60 days on NFTX? These are transactions where someone redeems their NFTX tokens for a specific NFT.

    Hint: You can find these sales in ez_nft_sales. Visualize your findings.
    */
    WITH NFTX_Proj_Vol AS (
    SELECT project_name, sum(price) as volume_nftx_token, sum(price_usd) AS volume_usd, sum(platform_fee_usd) AS platform_fees_usd, sum(creator_fee_usd) as creator_fees_usd,
    sum(total_fees_usd) AS total_fees_usd, sum(tx_fee_usd) AS Tx_fees_usd
    FROM ethereum.core.ez_nft_sales
    WHERE platform_name = 'nftx'
    AND BLOCK_TIMESTAMP > CURRENT_DATE-60
    AND event_type = 'redeem'
    GROUP BY 1
    ORDER BY 3 DESC
    ),
    TOP9_proj AS (
    SELECT project_name, volume_usd, rank() OVER (ORDER BY volume_usd DESC) AS vol_rank
    FROM NFTX_Proj_Vol
    ORDER BY volume_usd DESC
    LIMIT 9
    ),
    TOP10_proj AS (
    (SELECT * FROM TOP9_proj) UNION (
    SELECT 'Other' AS project_name, sum(volume_usd) AS volume_usd, 10 AS vol_rank
    FROM NFTX_Proj_Vol
    WHERE project_name NOT IN (SELECT project_name FROM TOP9_proj)
    )
    )

    SELECT *
    from TOP10_proj
    ORDER BY vol_rank
    Run a query to Download Data