datavortexTop buyers and sellers by volume
    Updated 2024-10-07
    WITH BuyerVolume AS (
    SELECT
    buyer_address AS "buyer address",
    SUM(price_usd) AS "buyer volume"
    FROM
    arbitrum.nft.ez_nft_sales
    WHERE
    block_timestamp >= CURRENT_TIMESTAMP - INTERVAL '30 DAY'
    GROUP BY
    buyer_address
    ORDER BY
    "buyer volume" DESC
    LIMIT
    5
    ), SellerVolume AS (
    SELECT
    seller_address AS "seller address",
    SUM(price_usd) AS "seller volume"
    FROM
    arbitrum.nft.ez_nft_sales
    WHERE
    block_timestamp >= CURRENT_TIMESTAMP - INTERVAL '30 DAY'
    GROUP BY
    seller_address
    ORDER BY
    "seller volume" DESC
    LIMIT
    5
    )
    SELECT
    'Top Buyers by Volume' AS category,
    NULL AS "seller address",
    "buyer address",
    CASE
    WHEN "buyer volume" >= 1e9 THEN TO_CHAR(ROUND("buyer volume" / 1e9, 2)) || 'B'
    WHEN "buyer volume" >= 1e6 THEN TO_CHAR(ROUND("buyer volume" / 1e6, 2)) || 'M'