--credit to misaghlb
SELECT
date(block_timestamp) as date,
from_address,
count(DISTINCT tx_hash) as tx_count,
sum(tx_fee) as tx_fee_volume,
avg(tx_fee) as avg_tx_fee,
row_number() over (partition by date order by tx_count DESC) as r
FROM gnosis.core.fact_transactions
WHERE block_timestamp >= CURRENT_DATE - 40
GROUP BY date, from_address
qualify r <= 10