Query editor
WITHparsed_data AS (SELECTCAST(address AS VARCHAR) as gauge,name as label,statusFROM labels.balancer_gauges),labels AS (SELECTgauge,label AS symbol,statusFROM parsed_data),vote_results AS (SELECTround_id,start_date,end_date,v.gauge,COALESCE(l.symbol,CONCAT('0x',LOWER(SUBSTRING(to_hex(v.gauge), 1, 4)),'...',LOWER(SUBSTRING(to_hex(v.gauge), 37, 4)))) AS symbol,l.status,SUM(vote) AS votesFROM balancer_ethereum.vebal_votes AS vLEFT JOIN labels l ON l.gauge = CAST(v.gauge AS VARCHAR)WHERE vote > 0 -- Include all positive votes, no matter how smallGROUP BY 1, 2, 3, 4, l.symbol, l.status),last_active_round AS (SELECTgauge,symbol,status,MAX(round_id) as last_round_id,MAX(end_date) as last_vote_dateFROM vote_resultsGROUP BY gauge, symbol, status),inactive_gauges AS (SELECTlar.gauge,lar.symbol,lar.status,lar.last_round_id,lar.last_vote_date,DATE_DIFF('day', lar.last_vote_date, CURRENT_DATE) as days_since_last_vote,vr.votes as last_vote_amount,vr.votes / CAST(tv.total_votes AS DOUBLE) as last_vote_percentageFROM last_active_round larLEFT JOIN vote_results vr ON vr.gauge = lar.gauge AND vr.round_id = lar.last_round_idLEFT JOIN (