select
block_timestamp::date as day,
tx_receiver,
avg(gas_used/POW(10,12)) as gas,
avg(gas) over (partition by tx_receiver order by day asc) as gas_trend
from
near.core.fact_transactions
where
block_timestamp > CURRENT_DATE-30 and
tx_receiver in (
select tx_receiver
from near.core.fact_transactions
group by tx_receiver
order by sum(gas_used) desc
limit 10
)
group by
tx_receiver, day
order by
tx_receiver, day asc