Query editor
with all_actions as (selectminter as user, evt_block_time as block_time, 'mint' as action_typefrom venus_bnb.vbep20delegate_v2_evt_mintwhere evt_block_time >= TIMESTAMP '2024-01-01'union allselectborrower as user, evt_block_time as block_time, 'borrow' as action_typefrom venus_bnb.vbep20delegate_v2_evt_borrowwhere evt_block_time >= TIMESTAMP '2024-01-01'union allselectminter as user, evt_block_time as block_time, 'mint' as action_typefrom venus_bnb.vbnb_v2_evt_mintwhere evt_block_time >= TIMESTAMP '2024-01-01'union allselectborrower as user, evt_block_time as block_time, 'borrow' as action_typefrom venus_bnb.vbnb_v2_evt_borrowwhere evt_block_time >= TIMESTAMP '2024-01-01'), user_activity as (selectuser, COUNT(*) as action_countfrom all_actionsgroup byuser), ranked_users as (selectuser, action_count, SUM(action_count) over () as total_actions, SUM(action_count) over (order byaction_count desc, user) as cumulative_actions, ROW_NUMBER() over (order byaction_count desc, user) as user_rank, COUNT(*) over () as total_usersfrom user_activity), bottom_50_threshold as (selectMAX(user_rank) as max_rankfrom ranked_userswhere user_rank <= CAST(total_users * 0.5 as BIGINT)