with
tx_details as (
select
block_timestamp,
tx_receiver,
GAS_USED/1e12 as giga_gas
from flipside_prod_db.mdao_near.transactions
)
select * from (
select
date(block_timestamp) as date,
tx_receiver as contract,
sum(giga_gas) as gas_total,
rank() over(partition by date order by gas_total desc) as rank
from tx_details
group by 1,2
order by gas_total desc
)
where rank <= 10
and date between '2022-06-27' and '2022-07-26'