WITH user_txn_counts AS (
SELECT
ACCOUNT,
COUNT(DISTINCT TRANSACTION_HASH) AS txn_count
FROM stellar.core.fact_transactions
WHERE BLOCK_TIMESTAMP >= DATEADD(YEAR, -1, CURRENT_DATE)
GROUP BY ACCOUNT
)
SELECT
AVG(txn_count) AS avg_txn_per_user,
APPROX_PERCENTILE(txn_count, 0.5) AS median_txn_per_user
FROM user_txn_counts;