Query editor
/*This query focuses on fixing the known issues with Price Feeds and CCIP data.It includes additional checks to identify the correct data sources.*//* First, let's examine fm_reward_daily to understand why Price Feed values are lower than expected */WITH PriceFeedAnalysis AS (SELECTDATE_TRUNC('month', date_start) AS month,SUM(usd_amount) AS monthly_fees,COUNT(*) AS transaction_count,MIN(usd_amount) AS min_fee,MAX(usd_amount) AS max_fee,AVG(usd_amount) AS avg_feeFROM chainlink.fm_reward_dailyWHEREdate_start >= CAST('2024-01-01' AS TIMESTAMP)GROUP BY1ORDER BY1 DESC), OCRAnalysis /* Check if ocr_reward_daily contains Price Feed data that we should include */ AS (SELECTDATE_TRUNC('month', date_start) AS month,SUM(usd_amount) AS monthly_fees,COUNT(*) AS transaction_countFROM chainlink.ocr_reward_dailyWHEREdate_start >= CAST('2024-01-01' AS TIMESTAMP)GROUP BY1ORDER BY1 DESC), CCIPAnalysis /* Analyze CCIP data to identify potential inclusion of non-user fees */ AS (SELECTDATE_TRUNC('month', date_start) AS month,SUM(usd_amount) AS monthly_fees,COUNT(*) AS transaction_count,MIN(usd_amount) AS min_fee,MAX(usd_amount) AS max_fee,AVG(usd_amount) AS avg_feeFROM chainlink.ccip_reward_dailyWHEREdate_start >= CAST('2024-01-01' AS TIMESTAMP)GROUP BY1ORDER BY1 DESC), CalendarQuarters AS (SELECTquarter_start,quarter_end,quarter_nameFROM (SELECTTRY_CAST('2024-01-01' AS DATE) AS quarter_start,TRY_CAST('2024-04-01' AS DATE) AS quarter_end,'Q1 2024' AS quarter_nameUNION ALLSELECTTRY_CAST('2024-04-01' AS DATE),