kasadeghUntitled Query
    Updated 2022-11-15
    with ethpricet as (
    select hour::date as day,
    avg (price) as USDPrice
    from ethereum.core.fact_hourly_token_prices
    where symbol = 'WETH'
    group by 1),
    maintable as (select 'Ethereum' as chain,
    from_address as spender,
    sum (tx_fee) as Gas,
    sum (tx_fee*usdprice) as USD_Gas,
    avg (tx_fee*usdprice) as Average_USD_Gas
    from ethereum.core.fact_transactions t1 join ethpricet t2 on t1.block_timestamp::Date = t2.DAY
    where block_timestamp >= CURRENT_DATE - 30
    group by 1,2

    )

    select 'wallet: '|| spender,
    chain,
    USD_Gas
    from maintable
    where usd_gas > 0 and chain='Ethereum'
    order by 3 DESC
    limit 10
    Run a query to Download Data