with df as (select
a.BLOCK_TIMESTAMP as BLOCK_TIMESTAMP,
a.TX_HASH as TX_HASH,
b.platform as platform,
a.TX_FEE as TX_FEE,
a.GAS_PRICE as GAS_PRICE,
a.GAS_USED as GAS_USED
from
ethereum.core.fact_transactions a
join ethereum.core.ez_dex_swaps b
on a.tx_hash = b.tx_hash)
SELECT
date_trunc('day', BLOCK_TIMESTAMP) as date,
sum(GAS_PRICE*GAS_USED) as gas_volume,
sum(tx_fee) as total_tx_fee,
sum (GAS_USED) as total_gas_used
from df
WHERE platform = 'uniswap-v2' and date >= '2021-05-05'
group by date