Query editor
WITHsrc AS (SELECTCAST(metric_date AS DATE) AS metric_date,CAST(date_trunc('month', metric_date) AS DATE) AS month_start,CAST(ethereum_daily_volume_usd AS DOUBLE) AS eth_vol,CAST(starknet_daily_volume_usd AS DOUBLE) AS sn_vol,CAST(ethereum_daily_fees_usd AS DOUBLE) AS eth_fee,CAST(starknet_daily_fees_usd AS DOUBLE) AS sn_fee,CAST(ethereum_daily_open_interest_usd AS DOUBLE) AS eth_oi,CAST(starknet_daily_open_interest_usd AS DOUBLE) AS sn_oi,CAST(balance_ethereum AS DOUBLE) AS eth_tvl,CAST(balance_starknet AS DOUBLE) AS sn_tvlFROM query_5730609),m AS (SELECTmonth_start,SUM(eth_vol) AS ethereum_monthly_volume_usd,SUM(sn_vol) AS starknet_monthly_volume_usd,SUM(eth_fee) AS ethereum_monthly_fees_usd,SUM(sn_fee) AS starknet_monthly_fees_usdFROM srcGROUP BY 1),eom_rank AS (SELECTmonth_start,metric_date,eth_oi, sn_oi, eth_tvl, sn_tvl,ROW_NUMBER() OVER (PARTITION BY month_start ORDER BY metric_date DESC) AS rnFROM src),eom AS (SELECTmonth_start,eth_oi AS ethereum_eom_open_interest_usd,sn_oi AS starknet_eom_open_interest_usd,eth_tvl AS eom_tvl_ethereum_usdc,sn_tvl AS eom_tvl_starknet_usdcFROM eom_rankWHERE rn = 1)SELECTm.month_start,m.ethereum_monthly_volume_usd,m.starknet_monthly_volume_usd,SUM(m.ethereum_monthly_volume_usd) OVER (ORDER BY m.month_start) AS ethereum_cumulative_volume_usd,SUM(m.starknet_monthly_volume_usd) OVER (ORDER BY m.month_start) AS starknet_cumulative_volume_usd,m.ethereum_monthly_fees_usd,m.starknet_monthly_fees_usd,SUM(m.ethereum_monthly_fees_usd) OVER (ORDER BY m.month_start) AS ethereum_cumulative_fees_usd,SUM(m.starknet_monthly_fees_usd) OVER (ORDER BY m.month_start) AS starknet_cumulative_fees_usd,