zackmendel1a. 50 and 20 days MA of DEX Txes
    Updated 2024-01-13
    WITH txes AS (
    SELECT
    date_trunc(day, block_timestamp) AS timespan,
    COUNT(DISTINCT tx_hash) AS transactions
    FROM crosschain.defi.ez_dex_swaps
    WHERE block_timestamp::date >= current_date - 365
    -- AND block_timestamp::date != current_date
    GROUP BY 1
    ORDER BY 1
    )
    SELECT
    timespan,
    transactions,
    avg (sum (transactions)) over (ORDER BY timespan rows between 20 PRECEDING AND current row) AS mov_ag_20days,
    avg (sum (transactions)) over (ORDER BY timespan rows between 50 PRECEDING AND current row) AS mov_avg_50days,
    avg (sum (transactions)) over (ORDER BY timespan rows between 200 PRECEDING AND current row) AS mov_avg_200days
    FROM txes
    GROUP BY 1,2
    ORDER BY 1
    QueryRunArchived: QueryRun has been archived