Query editor
withtransactions as (SELECTt.block_month as month,date_trunc('day',t.block_date) as "date", t.tx_hash as tx_hash, e.hash as hash--, address as address, t.total_gas_used as total_gas_used, e.gas_priceFROM safe_ethereum.transactions tJOIN ethereum.transactions AS eON t.tx_hash = e.hashGROUP BY1, 2,3,4,5,6), price as (SELECT date_trunc('day',minute) as date,avg(price) as avg_price from prices.usdwhere symbol = 'WETH'and blockchain = 'ethereum'GROUP BY 1), transactions_usd as(selectmonth, t.date, p.date, t.total_gas_used, p.avg_price, t.total_gas_used * t.gas_price * p.avg_price/pow(10, 18)as total_gas_used_usdFROM transactions AS tJOIN price AS pON t.date = p.date), percentiles as (SELECTmonth, MIN(total_gas_used_usd) AS min_gas, (APPROX_PERCENTILE(total_gas_used_usd, 0.25)) AS lower_quartile_gas, (APPROX_PERCENTILE(total_gas_used_usd, 0.5)) AS median_gas, (APPROX_PERCENTILE(total_gas_used_usd, 0.75)) AS upper_quartile_gas, (APPROX_PERCENTILE(total_gas_used_usd, 0.80)) AS "80th_percentile"