BigQuery - How to find BitCoin input addresses for a specific output address

Viewed 393

BigQuery Public Data Set: Crypto_Bitcoin

I've been trying to identify all the unique input (sender) addresses that are sending Bitcoins to a specific address (e.g. XXX). Despite feeling this to be a straightforward query based on the Database Schema, I am getting errors despite countless attempts. Could anyone please help identify what's the issue here:

SELECT DISTINCT inputs.addresses FROM bigquery-public-data.crypto_bitcoin.transactions as transactions, transactions.inputs as inputs WHERE outputs.addresses = "XXX"

Thanks

Data Schema

1 Answers

Below is for BigQuery Standard SQL

Try below

SELECT DISTINCT input_address
FROM `bigquery-public-data.crypto_bitcoin.transactions` AS transactions, 
  transactions.inputs AS input, input.addresses AS input_address,
  transactions.outputs AS output, output.addresses AS output_address
WHERE output_address = "XXX"
Related