Query editor
WITH smart_contracts_list AS (SELECT distinct addressFROM linea.tracesWHERE "type" LIKE 'create%'AND address IS NOT NULLAND successAND code != 0xAND code IS NOT NULL),-- First get the distinct wallets with their first tx datewallet_first_tx AS (SELECTt."from" AS wallet,MIN(t.block_time) AS first_transaction_dateFROM linea.transactions tWHERE NOT EXISTS (SELECT 1 FROM smart_contracts_list scWHERE sc.address = t."from")GROUP BY t."from"),-- Then get recent transaction counts (last 30 days)recent_tx_counts AS (SELECTt."from" AS wallet,COUNT(*) AS total_transactions_last_30_days,MAX(t.block_time) AS last_transaction_dateFROM linea.transactions tWHERE NOT EXISTS (SELECT 1 FROM smart_contracts_list scWHERE sc.address = t."from")AND t.block_time >= NOW() - INTERVAL '30' dayGROUP BY t."from")SELECTw.wallet,COALESCE(r.total_transactions_last_30_days, 0) AS total_transactions_last_30_days,w.first_transaction_date,r.last_transaction_dateFROM wallet_first_tx wLEFT JOIN recent_tx_counts r ON w.wallet = r.walletWHERE r.total_transactions_last_30_days > 0 -- Only include wallets with recent activityORDER BY r.total_transactions_last_30_days DESC NULLS LAST,r.last_transaction_date DESC NULLS LASTLIMIT 1000;