hbd19942. Weekly Overview
    Updated 2022-11-15
    with maintable as (
    select
    *,
    case
    when action in ('DelegatorTokensCommitted','TokensCommitted') then 'Stake'
    when action in ('DelegatorUnstakedTokensWithdrawn','UnstakedTokensWithdrawn') then 'Unstake' end as action_type
    from flow.core.ez_staking_actions
    where tx_succeeded = 'TRUE'
    and action not in ('DelegatorRewardTokensWithdrawn', 'RewardTokensWithdrawn') -- about reward
    and amount > 0)
    select
    date_trunc('week' ,block_timestamp::date) as "Weekly Date",
    action_type,
    count(distinct tx_id) as "Number of Transacions",
    count(distinct delegator) as "Number of Users",
    count(distinct NODE_ID) as "Number of Nodes",
    sum(amount) as "Total Volume",
    avg(amount) as "Average Volume",
    max(amount) as "Maximum Volume",
    min(amount) as "Minimum Volume"
    from maintable
    group by 1 , 2
    order by 1
    Run a query to Download Data