with rewards as (
select
address,
sum(rewards_total) as rewards_total
from algorand.account
where account_closed = 'FALSE' and wallet_type is not null
group by address
), tx as (
select
sender,
count(distinct(tx_id)) as total_transactions
from algorand.transactions
where inner_tx = 'FALSE' and sender in (select distinct address from rewards)
group by sender
)
select
a.sender,
a.total_transactions,
b.rewards_total
from tx a
inner join rewards b
on a.sender = b.address
where a.sender = b.address
order by b.rewards_total desc
limit 1000