yasminMarketplace Sales Distribution copy
    Updated 2024-09-11
    WITH traders AS (
    SELECT
    date_trunc('week', block_timestamp) AS date,
    COUNT(DISTINCT CASE WHEN seller_address IS NOT NULL THEN seller_address
    WHEN buyer_address IS NOT NULL THEN buyer_address
    END) AS n_traders
    FROM
    aptos.nft.ez_nft_sales
    WHERE
    EVENT_TYPE = 'sale'
    AND platform_name in (
    '{{platform_name}}')
    AND block_timestamp::date >= '{{Start_Date}}' AND block_timestamp::date <= '{{End_Date}}'

    GROUP BY
    1
    )

    SELECT
    traders.date,
    traders.n_traders,
    sales.transactions,
    sales.volume_APT
    FROM
    traders
    JOIN
    (
    SELECT
    date_trunc('week', block_timestamp) AS date,
    COUNT(DISTINCT TX_HASH) AS transactions,
    SUM(TOTAL_PRICE) AS volume_APT
    FROM
    aptos.nft.ez_nft_sales
    WHERE
    EVENT_TYPE = 'sale'
    AND platform_name in (