Query editor
WITH user_stats AS (SELECT"from" AS address,COUNT(*) AS tx_count,COUNT(DISTINCT date_trunc('day', block_time)) AS active_daysFROM plume.transactionsGROUP BY 1),categorized_users AS (SELECTCASEWHEN tx_count >= 100 THEN 'Power Users (100+ tx)'WHEN tx_count >= 50 THEN 'Heavy Users (50-99 tx)'WHEN tx_count >= 20 THEN 'Regular Users (20-49 tx)'WHEN tx_count >= 5 THEN 'Casual Users (5-19 tx)'ELSE 'One-time Users (1-4 tx)'END AS "User Category",COUNT(DISTINCT address) AS "Users Count",SUM(tx_count) AS "Total Transactions",ROUND(AVG(active_days), 1) AS "Avg Active Days",ROUND(AVG(tx_count), 1) AS "Avg Tx per User"FROM user_statsGROUP BY 1)SELECT *,CASEWHEN "User Category" = 'One-time Users (1-4 tx)' THEN 1WHEN "User Category" = 'Casual Users (5-19 tx)' THEN 2WHEN "User Category" = 'Regular Users (20-49 tx)' THEN 3WHEN "User Category" = 'Heavy Users (50-99 tx)' THEN 4WHEN "User Category" = 'Power Users (100+ tx)' THEN 5END AS "Category Order"FROM categorized_usersORDER BY "Category Order"