permarypagnolin vilume
    Updated 2024-11-02
    with quarterly_data as (
    select
    DATE_TRUNC('day', date) as day,
    protocol,
    chain,
    case
    when date >= '2024-01-01' and date < '2024-04-01' then 'Q1-2024'
    when date >= '2024-04-01' and date < '2024-07-01' then 'Q2-2024'
    when date >= '2024-07-01' and date < '2024-10-01' then 'Q3-2024'
    when date >= '2024-10-01' and date < '2025-01-01' then 'Q4-2024'
    END as quarter,
    SUM(volume) as daily_volume
    from external.defillama.fact_dex_volume
    WHERE protocol ILIKE '%pangolin%'
    and chain ILIKE '%Avalanche%'
    and date between '2024-01-01' and '2024-12-31'
    group by DATE_TRUNC('day', date), protocol, chain, quarter
    ),
    cumulative_quarterly_volume as (
    select
    day,
    protocol,
    chain,
    quarter,
    SUM(daily_volume) over (partition by protocol, quarter order by day) as cumulative_volume
    from quarterly_data
    )
    select * from cumulative_quarterly_volume
    order by day, protocol;

    QueryRunArchived: QueryRun has been archived