Query editor
WITH Latest_Action3_Timestamps AS (-- Get the latest actionType 3 timestamp for each provider who used actionType = 3SELECTprovider,evt_tx_hash,MAX(evt_block_time) AS latest_action3_timeFROMsperax_arbitrum.veSPA_v1_evt_UserCheckpointWHEREactionType = 3GROUP BYprovider, evt_tx_hash),Latest_Action3_Filtered AS (-- Filter to the rows where actionType = 3 was used at the latest timestampSELECTu.*FROMsperax_arbitrum.veSPA_v1_evt_UserCheckpoint AS uJOINLatest_Action3_Timestamps AS lON u.provider = l.provider AND u.evt_block_time = l.latest_action3_timeWHEREu.actionType = 3),UserCheckpoint_Never_Used_Action3 AS (-- Find rows for providers who have never used actionType = 3 and only used actionType = 1SELECT *FROM sperax_arbitrum.veSPA_v1_evt_UserCheckpointWHEREevt_tx_hash NOT IN (SELECT evt_tx_hash FROM Latest_Action3_Timestamps)AND actionType = 1),Combined_Data AS (-- Combine the results from both sets: those who used actionType 3 and those who have notSELECT * FROM Latest_Action3_FilteredUNION ALLSELECT * FROM UserCheckpoint_Never_Used_Action3),Withdrawn_Count AS (-- Calculate the count of distinct withdrawn transactionsSELECTCOUNT(DISTINCT evt_tx_hash) AS withdrawn_countFROMsperax_arbitrum.veSPA_v1_evt_Withdraw),Locks_Within_Timeframes AS (-- Count each timeframeSELECT'6 months' AS time_category,COUNT(*) - (SELECT withdrawn_count FROM Withdrawn_Count) AS lock_countFROMCombined_DataWHERElocktime < TO_UNIXTIME(CURRENT_TIMESTAMP + INTERVAL '6' month)UNION ALLSELECT'1 year' AS time_category,