Query editor
WITH interactions AS (SELECTDATE_TRUNC('day', t.block_time) AS day,t."from" AS user,t.gas_used,t.gas_priceFROM apechain.transactions tWHERE t."to" = 0x2d342ef1c5dea66851a3e604c9e663836405cf54AND t.success = TRUEUNION ALLSELECTDATE_TRUNC('day', tr.block_time) AS day,tr.tx_from AS user,tr.gas_used,tx.gas_priceFROM apechain.traces trJOIN apechain.transactions tx ON tx.hash = tr.tx_hashWHERE tr.address = 0x2d342ef1c5dea66851a3e604c9e663836405cf54AND tr.success = TRUE)SELECTuser,COUNT(*) AS total_interactions,COUNT(DISTINCT day) AS active_days,ROUND(COUNT(*) * 1.0 / COUNT(DISTINCT day), 2) AS avg_interactions_per_day,SUM(gas_used * gas_price) / 1e18 AS total_fees_spent_ape,MIN(day) AS first_interaction,MAX(day) AS latest_interactionFROM interactionsGROUP BY userORDER BY total_interactions DESC;