This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################### | |
Generate unique integer index for a transaction | |
############################################### | |
SELECT | |
txns.hash as transaction_hash | |
, (999999 - txns.block_number) as block_index | |
, (999999 - ROW_NUMBER() OVER (PARTITION BY block_number ORDER BY txns.hash) + 1) as tx_index_in_block | |
, 1000000 * (999999 - txns.block_number) + (999999 - ROW_NUMBER() OVER (PARTITION BY block_number ORDER BY txns.hash) + 1) as unique_tx_index | |
FROM `bigquery-public-data.crypto_bitcoin.transactions` as txns |
OlderNewer