select
count(distinct(tx_hash)) as tx_num,
avg(price) as avg_price,
avg_price * sum(gas_used/ pow (10, 9)) as total_amount,
(total_amount / (avg_price * sum(eth_value) / pow(10, 6))) as average_cost,
(total_amount / tx_num) as avg_amount_per_txn
from ethereum.core.fact_hourly_token_prices
join ethereum.core.fact_transactions
on block_timestamp::date = hour::date
where 1 = 1
and block_timestamp::date > '2022-10-01'
and token_address is null