i_danWeekly Stats 1 copy
    Updated 2025-02-26
    SELECT
    date_trunc('week', block_timestamp) AS week
    , SUM(CASE WHEN amount_in_usd IS NULL THEN amount_out_usd ELSE amount_in_usd END) AS volume
    , SUM(volume) over (ORDER BY week) AS "Cumulative Volume"
    , COUNT(DISTINCT(tx_hash)) AS tx_count
    , SUM(tx_count) OVER (ORDER BY week) AS "Cumulative Transactions"
    , COUNT(DISTINCT(origin_from_address)) AS wallet_count
    , CASE WHEN week > trunc(current_date, 'week') - INTERVAL '1 week' THEN 'Current Week'
    WHEN week = trunc(current_date, 'week') - INTERVAL '1 week' THEN 'Last Week'
    ELSE 'Previous Weeks' end AS label
    FROM kaia.defi.ez_dex_swaps
    WHERE block_timestamp >= '2025-01-01'
    GROUP BY 1
    ORDER BY 1 DESC
    QueryRunArchived: QueryRun has been archived