misaghlbAave Delegates' Gas Usage - gas 90 days
    Updated 2023-03-22
    with eth_price as (
    SELECT date(hour) as pdate, avg(price) as avg_price
    from ethereum.core.fact_hourly_token_prices
    where date(hour) >= CURRENT_DATE - 90
    AND symbol = 'WETH'
    GROUP BY pdate
    )
    SELECT
    date(a.block_timestamp) as date,
    sum(tx_fee) as "Total Fee",
    sum("Total Fee") over (order by date asc) as "Cumulative Fee",
    sum(tx_fee * avg_price) as "Total Fee(USD)",
    sum("Total Fee(USD)") over (order by date asc) as "Cumulative Fee(USD)",
    avg(tx_fee) as "Average Fee",
    avg(tx_fee * avg_price) as "Average Fee(USD)",
    sum(gas_used / 1e9) as "Total Gas",
    avg(gas_used / 1e9) as "Average Gas"
    FROM ethereum.aave.ez_votes a
    JOIN ethereum.core.fact_transactions b ON a.tx_hash = b.tx_hash
    JOIN eth_price on date(a.block_timestamp) = pdate
    where date(a.block_timestamp) >= CURRENT_DATE - 90
    GROUP BY date


    Run a query to Download Data