mucryptoethereum b
    Updated 2023-03-15
    with eth_b as (select
    date_trunc('day', block_timestamp) as day,
    sum (gas_used * block_header_json:base_fee_per_gas) / 1e18 as eth_fees_daily,
    sum (eth_fees_daily) over (order by day asc) as eth_fees_cm
    from ethereum.core.fact_blocks
    where block_timestamp::date between '2022-05-04' and '2022-05-15'
    group by 1),

    eth_prices as (select
    hour::date as day,
    avg(price) as eth_price_daily
    from ethereum.core.fact_hourly_token_prices
    where token_address is null
    and hour::date between '2022-05-04' and '2022-05-15'
    group by 1),

    total_fees_b as (select
    b.day,
    eth_fees_daily,
    eth_price_daily * eth_fees_daily as eth_fees_daily_usd,
    eth_fees_cm,
    sum(eth_fees_daily_usd) over (order by b.day asc) as eth_fees_cm_usd
    from eth_b b
    join eth_prices e on b.day=e.day
    group by 1,2,3,4)

    select * from total_fees_b
    Run a query to Download Data