RamaharContracts Active Daily copy
Updated 2024-06-25
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
-- 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