andre4trader joe nft stats by collection 2
    Updated 2024-09-30
    -- forked from trader joe nft stats by collection @ https://flipsidecrypto.xyz/studio/queries/918df9e0-ab83-4cfe-9654-07d9b012a08f

    WITH top_projects AS (
    SELECT
    project_name
    FROM
    avalanche.nft.ez_nft_sales
    WHERE
    platform_name = 'joepegs' and block_timestamp>=current_date-INTERVAL '1 WEEK'
    GROUP BY
    project_name
    ORDER BY
    SUM(price_usd) DESC
    LIMIT 10
    ),
    joe as (
    SELECT
    DATE_TRUNC('day', block_timestamp) AS time,
    project_name,
    buyer_address,
    tx_hash,
    price_usd AS volume
    FROM
    avalanche.nft.ez_nft_sales
    WHERE
    DATE_TRUNC('day', block_timestamp) < DATE_TRUNC('day', CURRENT_DATE)
    AND platform_name = 'joepegs'
    --AND project_name IN (SELECT project_name FROM top_projects)
    AND block_timestamp>=current_date-INTERVAL '1 WEEK'
    ),
    alls AS (
    SELECT
    time,
    project_name,
    COUNT(DISTINCT tx_hash) AS sales,
    COUNT(DISTINCT buyer_address) AS active_users,
    QueryRunArchived: QueryRun has been archived