andre4trader joe stats 2
    Updated 2024-09-30
    WITH
    joe AS (
    SELECT
    DATE_TRUNC('day', block_timestamp) AS time,
    currency_symbol,
    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 time>=current_date-INTERVAL '1 week'
    ),
    alls AS (
    SELECT
    time,
    COUNT(DISTINCT tx_hash) AS sales,
    COUNT(DISTINCT buyer_address) AS active_users,
    SUM(volume) AS volume,
    AVG(volume) AS avg_price
    FROM joe
    GROUP BY 1
    ),
    alls2 AS (
    SELECT
    time,
    sales,
    SUM(sales) OVER (ORDER BY time) AS total_sales,
    volume,
    SUM(volume) OVER (ORDER BY time) AS total_volume,
    avg_price
    FROM alls
    ORDER BY time DESC
    )
    SELECT * FROM alls2 order by time desc


    QueryRunArchived: QueryRun has been archived