Query editor
WITH rewards AS (SELECTdate_trunc('hour', block_time) AS time_rewarded,'map and trainer' AS reward_type_group,round(amount / pow(10, 9), 4) AS amount_rewarded,to_ownerFROM hivemapper_solana.rewardsWHERE reward_type IN('map coverage', 'QA (AI Trainer)')ORDER BY block_date DESC),current_honey_balance AS (SELECTtoken_balance_owner AS to_owner,SUM(CASE WHEN token_mint_address = '4vMsoUT2BWatFweudnQM1xedRLfJgJ7hswhcpz4xgBTy'THEN token_balanceELSE 0 END) AS current_honey_tokensFROM solana_utils.latest_balancesWHERE token_balance_owner IS NOT NULLGROUP BY token_balance_owner)SELECTreward_type_group,r.to_owner,SUM(amount_rewarded) AS honey_rewarded_total,chb.current_honey_tokens,round(chb.current_honey_tokens - SUM(amount_rewarded), 4) AS balance_differenceFROM rewards rJOIN current_honey_balance chb ON r.to_owner = chb.to_ownerWHERE reward_type_group = 'map and trainer'AND (time_rewarded >= CAST('{{start_date}}' AS timestamp) AND time_rewarded <= CAST('{{end_date}}' AS timestamp))GROUP BY r.to_owner, reward_type_group, chb.current_honey_tokensHAVING SUM(amount_rewarded) > 10ORDER BY r.to_owner DESC