with data_tx as (
select
distinct tx_group_id
from
algorand.transactions
where
-- tx_group_id = '+JaQWvUgft6dgzaCMzjXcAIqPz9dj1qSdFHz7Bn1p+E='
try_base64_decode_string(tx_message:txn:note::string) = 'Market: mt'
and tx_type = 'appl'
and tx_message:txn:apid = 465814318
), data_address as (
select
distinct receiver as address
from algorand.payment_transaction
where
tx_group_id in (select tx_group_id from data_tx)
)
select sum(balance) as total from
algorand.account where address in (select address from data_address)