RamaharContracts Active Daily copy
    Updated 2024-06-25
    -- forked from cloudr3n / Contracts Active Daily @ https://flipsidecrypto.xyz/cloudr3n/q/XWynlMzdP5Oh/contracts-active-daily

    with
    daily_contracts as (
    select
    date(block_timestamp) as day,
    count(distinct contract_address) as active_contracts,
    sum(active_contracts) over (order by day rows between unbounded preceding and current row) as cumu_contracts,
    avg(active_contracts) over (order by day rows between 6 preceding and current row) as rolling_avg
    -- add 7d or Q4 average

    from
    avalanche.core.fact_event_logs
    where
    1=1
    and block_timestamp between '{{StartDate}}' and '{{EndDate}}'
    group by day
    ),

    total_contracts as (
    select
    count(distinct contract_address) as active_contracts_quarter
    from
    avalanche.core.fact_event_logs
    where
    1=1
    and block_timestamp between '{{StartDate}}' and '{{EndDate}}'
    )

    select * from daily_contracts
    full outer join total_contracts



    QueryRunArchived: QueryRun has been archived