Query editor
with price_pol as (selectdate_trunc('day', timestamp) as day,max(price) as pricefrom prices.daywhere blockchain = 'ethereum' and contract_address in (0x455e53cbb86018ac2b8092fdcd39d8444affc3f6, 0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0) -- POL, MATICand timestamp < date_trunc('hour', now())and timestamp >= now() - interval '{{hours}}' hour - interval '25' hourGROUP BY 1),price_eth as (selectdate_trunc('day', timestamp) as day,pricefrom prices.daywhere blockchain = 'ethereum' and contract_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 -- ETHand timestamp < date_trunc('hour', now())and timestamp >= now() - interval '{{hours}}' hour - interval '25' hour),prices as (selectpol.day,pol.price as price_pol,eth.price as price_eth,pol.price/eth.price as pol_per_ethfrom price_pol polinner join price_eth eth on pol.day = eth.day)selectdate_trunc('hour', block_time) as "timestamp",'polygon_pos' as origin_key,count(*) FILTER (WHERE gas_price > 0) as txcount,count(*) as txcount_plain,count(*) as txcount_comparison,SUM(gas_used) / (60 * 60) AS gas_per_second,--COUNT(distinct "from") AS daa,SUM((gas_used / POWER(10,18) * cast(gas_price as DOUBLE)) * pol_per_eth) AS fees_paid_eth,approx_percentile((gas_used / POWER(10,18) * cast(gas_price as DOUBLE)) * pol_per_eth, 0.5) FILTER (WHERE gas_price > 0) as txcosts_median_eth,count(distinct "from") as daafrom polygon.transactions tleft join prices p on t.block_date = p.daywhere block_date >= date_trunc('day', now() - interval '{{hours}}' hour) -- for better partitioningand block_time < date_trunc('hour', now())and block_time >= date_trunc('hour', now() - interval '{{hours}}' hour)group by 1