Query editor
WITH BLOCKS AS (SELECTdate_trunc('day', time) AS day,date_trunc('week', time) AS week, SUM(total_fees) AS total_fees, SUM(transaction_count) AS transaction_count, SUM(Total_reward) AS total_reward, SUM(mint_reward) AS total_mint_rewardFROM bitcoin.blocksWHERE time >= CAST('2023-01-01' AS TIMESTAMP(3) WITH TIME ZONE)GROUP BY 1,2), DataTable1 AS (SELECTday,week, total_fees, transaction_count,total_reward,total_mint_reward, ((total_fees - LAG(total_fees, 7) OVER (ORDER BY day)) / LAG(total_fees, 7) OVER (ORDER BY day)) * 100 AS week_over_week_total_fees_percent, ((total_reward - LAG(total_reward, 7) OVER (ORDER BY day)) / LAG(total_reward, 7) OVER (ORDER BY day)) * 100 AS week_over_week_total_reward_percent, ((total_mint_reward - LAG(total_mint_reward, 7) OVER (ORDER BY day)) / LAG(total_mint_reward, 7) OVER (ORDER BY day)) * 100 AS week_over_week_total_mint_reward_percent,sum(total_fees) over (order by day) as Cumulative_fees,sum(transaction_count) over (order by day) as Cumulative_transaction,sum(total_reward) over (order by day) as Cumulative_reward,sum(total_mint_reward) over (order by day) as Cumulative_mint_rewardFROM BLOCKSORDER BY 1 DESC)select * from DataTable1