Query editor
WITH details AS (SELECT0x18084fbA666a33d37592fa2633fd49a74dd93a88 AS token, /* tBTC token address */18 AS dec /* Decimal precision for tBTC */), transfer1 AS (SELECTt.contract_address,t."to" AS address, /* Now focusing on the 'to' field for the destination addresses */t.evt_tx_hash AS sourceTxHash,et.block_time AS initiatedAt_UTC,'Ethereum' AS sourceChain, /* Assuming transfers are on the Ethereum chain */'Ethereum' AS destChain, /* Same assumption for the destination chain */t."from" AS sourceWallet, /* The bridge contract is now the source */TRY_CAST(t.value AS DOUBLE) / POWER(10, d.dec) AS amount,et.data AS transactionData /* Fetching the data column from transactions */FROM erc20_ethereum.evt_Transfer AS tJOIN ethereum.transactions AS etON t.evt_tx_hash = et.hashLEFT JOIN details AS dON t.contract_address = d.tokenWHEREt.contract_address = d.tokenAND t."from" = 0x3ee18b2214aff97000d974cf647e7c347e8fa585 /* Filtering for bridge contract as the sender */)SELECTROW_NUMBER() OVER (ORDER BY sub.balance_amount DESC) AS Rank_id,sub.initiatedAt_UTC AS initiatedAt_UTC,sub.destinationWallet AS destinationWallet, /* Now the recipient wallets */sub.sourceTxHash AS sourceTxHash,sub.sourceChain AS sourceChain,sub.destChain AS destChain,sub.sourceWallet AS sourceWallet, /* Bridge contract as source */CAST(sub.tBTC_amt AS DECIMAL(18,6)) AS tBTC_amt,sub.transactionData /* Include the data column in your final selection */FROM (SELECTtt.address AS destinationWallet,tt.sourceTxHash AS sourceTxHash,tt.initiatedAt_UTC AS initiatedAt_UTC,tt.sourceChain AS sourceChain,tt.destChain AS destChain,tt.sourceWallet AS sourceWallet, /* Bridge contract */SUM(tt.amount) AS balance_amount,tt.amount AS tBTC_amt,tt.transactionData /* Carry the data column through to the subquery */FROM transfer1 AS ttGROUP BYtt.address,tt.sourceTxHash,tt.initiatedAt_UTC,tt.sourceChain,tt.destChain,tt.sourceWallet,tt.amount,tt.transactionData /* Grouping by transactionData */) AS subORDER BYbalance_amount DESC