freshgeek2024-06-04 01:11 AM
    Updated 2024-06-04
    WITH swap_overview AS (
    SELECT
    DATE_TRUNC('day', BLOCK_TIMESTAMP) AS swap_date,
    PLATFORM,
    SYMBOL_IN,
    SYMBOL_OUT,
    SUM(AMOUNT_IN) AS total_amount_in,
    SUM(AMOUNT_IN_USD) AS total_amount_in_usd,
    SUM(AMOUNT_OUT) AS total_amount_out,
    SUM(AMOUNT_OUT_USD) AS total_amount_out_usd,
    COUNT(EZ_DEX_SWAPS_ID) AS total_swaps

    FROM
    avalanche.defi.ez_dex_swaps

    WHERE
    BLOCK_TIMESTAMP >= '2024-01-01' AND BLOCK_TIMESTAMP < '2025-01-01'
    GROUP BY
    swap_date,
    PLATFORM,
    SYMBOL_IN,
    SYMBOL_OUT
    )
    SELECT
    swap_date,
    PLATFORM,
    SYMBOL_IN,
    SYMBOL_OUT,
    total_amount_in,
    total_amount_in_usd,
    total_amount_out,
    total_amount_out_usd,
    total_swaps
    FROM
    swap_overview
    ORDER BY
    QueryRunArchived: QueryRun has been archived