SELECT
date_trunc('DAY', block_timestamp) as fecha,
COUNT(distinct tx_group_id),
COUNT(distinct tx_id),
CASE tx_message:txn:apid
WHEN 354073834 then 'ASA'
WHEN 354073718 then 'ALGO'
END AS ESCROW
FROM algorand.transactions
WHERE
fecha >= '2022-01-01'
AND tx_message:txn:apid IN (354073834, 354073718)
GROUP BY fecha, ESCROW
ORDER BY fecha