select
s.value as signer,
count(distinct b.tx_id) as transactions,
sum(b.fee / array_size(b.signers)) / 1e9 as total_fees
from solana.fact_transactions b,
lateral flatten( input => b.signers ) s,
lateral flatten( input => b.account_keys ) a
where
date_trunc('month',date(b.block_timestamp)) = date('2021-10-01') and
b.succeeded and
a.value['pubkey'] = 'dammHkt7jmytvbS3nHTxQNEcP59aE57nxwV21YdqEDN'
group by 1