Query editor
-- Aggregate position claimable amounts by end dayWITH daily_aggregates AS (SELECTend_day,-- Total amounts ending this daySUM(principal_tokens) as total_principal_ending,SUM(rewards_tokens) as total_rewards_ending,SUM(total_claimable_tokens) as total_claimable_ending,-- Creation positions ending this daySUM(CASE WHEN position_type = 'creation' THEN principal_tokens ELSE 0 END) as creation_principal_ending,SUM(CASE WHEN position_type = 'creation' THEN rewards_tokens ELSE 0 END) as creation_rewards_ending,SUM(CASE WHEN position_type = 'creation' THEN total_claimable_tokens ELSE 0 END) as creation_total_ending,-- Staked positions ending this daySUM(CASE WHEN position_type = 'staked' THEN principal_tokens ELSE 0 END) as staked_principal_ending,SUM(CASE WHEN position_type = 'staked' THEN rewards_tokens ELSE 0 END) as staked_rewards_ending,SUM(CASE WHEN position_type = 'staked' THEN total_claimable_tokens ELSE 0 END) as staked_total_ending,-- Position countsCOUNT(*) as total_positions_ending,COUNT(CASE WHEN position_type = 'creation' THEN 1 END) as creation_positions_ending,COUNT(CASE WHEN position_type = 'staked' THEN 1 END) as staked_positions_ending,-- User countsCOUNT(DISTINCT "user") as unique_users,COUNT(DISTINCT CASE WHEN position_type = 'creation' THEN "user" END) as creation_users_ending,COUNT(DISTINCT CASE WHEN position_type = 'staked' THEN "user" END) as staked_users_endingFROM query_5460191GROUP BY end_day)SELECT*,-- Cumulative breakdownsSUM(total_claimable_ending) OVER (ORDER BY end_day ASC ROWS UNBOUNDED PRECEDING) as cumulative_future_supply,SUM(total_principal_ending) OVER (ORDER BY end_day ASC ROWS UNBOUNDED PRECEDING) as cumulative_principal_supply,SUM(total_rewards_ending) OVER (ORDER BY end_day ASC ROWS UNBOUNDED PRECEDING) as cumulative_rewards_supplyFROM daily_aggregatesORDER BY end_day ASC