Query editor
-- DUNE Query to fetch Gas Prices by day in the past 7 days--> Offers insight into gas price trends, allowing developers and users to identify patterns and potentially cheaper transaction windows.--> Provides a perspective on the network's congestion levels over a week-- Using a CTE (Common Table Expression) named 'day_aggregate' to aggregate gas price metrics for each day of the week over the past 7 daysWITHday_aggregate AS (SELECT-- Extract the day of the week (integer representation) from the block_time columnEXTRACT (DOW FROM block_time) AS weekday,-- Compute the average gas price, converting it from wei to Gwei and rounding the result to 2 decimalsROUND(AVG(gas_price)/1e9, 2) AS avg_gas_price,-- Compute the median gas price using APPROX_PERCENTILE function, convert the result to Gwei, and round to 2 decimalsROUND(APPROX_PERCENTILE(gas_price,0.5)/1e9, 2) AS median_gas_price,-- Compute the 90th percentile of gas price, convert the result to Gwei, and round to 2 decimalsROUND(APPROX_PERCENTILE(gas_price,0.9)/1e9, 2) AS nine_tenth_gas_priceFROM ethereum.transactions-- Apply filter to consider only the transactions from the past 7 daysWHERE block_time >= (NOW() - INTERVAL '7' DAY)-- Group the results by the day of the week to get aggregated metrics for each dayGROUP BY EXTRACT (DOW FROM block_time))-- Main query to transform numeric representation of weekdays to their string names and select required metrics for each daySELECT-- Map numeric weekday values to their respective namesCASEWHEN weekday = 1 THEN 'Monday'WHEN weekday = 2 THEN 'Tuesday'WHEN weekday = 3 THEN 'Wednesday'WHEN weekday = 4 THEN 'Thursday'WHEN weekday = 5 THEN 'Friday'WHEN weekday = 6 THEN 'Saturday'WHEN weekday = 7 THEN 'Sunday'END AS "Week weekday",-- Select weekday and gas metrics from the CTEweekday,avg_gas_price AS "Average",median_gas_price AS "Median",nine_tenth_gas_price AS "0.9 Percentile"-- Use the 'day_aggregate' CTE as the data source for the main queryFROMday_aggregate-- Sort the results by the day of the week in ascending order (typically Sunday to Saturday or Monday to Sunday based on system)ORDER BY weekday;