IBC_insiderterra p1 3
    Updated 2022-12-28
    with t1 as
    (select avg(FEE) as fee , date_trunc('day',BLOCK_TIMESTAMP ) as date
    from
    terra.core.fact_transactions

    group by date )
    ,
    price as
    (select avg(CLOSE) as price ,date_trunc('day',RECORDED_HOUR ) as datee from crosschain.core.fact_hourly_prices
    where
    ID = 'terra-luna-2'
    group by 2)
    , lom as
    (select *,FEE*price as feeusd,
    sum(feeusd) over (order by date)
    from t1 a inner join price b
    on a.date=b.datee)

    select date_trunc('week',date) as doty , avg(feeusd)
    from lom
    group by 1

    Run a query to Download Data