Query editor
WITH revenue AS (SELECTcoin_address, block_time, DATE_TRUNC('month', block_time) AS block_date, MONTH(block_time) AS block_month, YEAR(block_time) AS block_year-- , -- Monday 00:00 of the same week-- date_add('day', 1 - day_of_week(block_time), date_trunc('day', block_time)) as week_start, reason_name, amount_usd, pool_type, currency_address, recipient_addressFROM dune.zorateam.result_zora_coin_rewardsWHERE (recipient_address = 0x7bf90111Ad7C22bec9E9dFf8A01A44713CC1b1B6 OR recipient_address = 0x67421e82E0157a3CA9508Ee92F6417A93BBf59CB)AND block_time > ((current_date) - INTERVAL '7' MONTH)), daily_revenue AS (SELECTblock_month, block_year, block_date-- , week_start, SUM(amount_usd) AS revenue_usdFROM revenueGROUP BY 1, 2, 3),lagged AS (SELECTconcat(cast(block_month as VARCHAR),'-',cast(block_year as VARCHAR)) As month_year, block_year, block_month, block_date-- , week_start, revenue_usd, lag(revenue_usd, 1) OVER (ORDER BY block_year, block_month) as prev-- , lag(revenue_usd, 1) OVER (ORDER BY block_year, block_month)FROM daily_revenueORDER BY 1-- block_month, block_year DESC)SELECTblock_year, block_month, block_date, revenue_usd, (revenue_usd - prev) / prev AS percent_changeFROM laggedorder by block_date