with maintable as (
select origin_from_address,
amount,
block_timestamp,
row_number () over (partition by origin_from_address order by block_timestamp asc) as rn
from crosschain.olas.ez_olas_staking)
select date_trunc ({{Time_Interval}},block_timestamp) as date,
case when rn = '1' then 'New Stakers' when rn > 1 then 'Existing Stakers' end as type,
count (distinct origin_from_address) as Stakers,
sum (amount) as Staked_Volume_OLAS
from maintable
group by 1,2
order by 1 desc