Created
August 22, 2021 20:41
-
-
Save rvrsh3ll/84cd67e1cc170111f3c47a1841902346 to your computer and use it in GitHub Desktop.
This file contains 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
with double_entry_book as ( | |
-- debits | |
SELECT | |
array_to_string(inputs.addresses, ",") as address | |
, block_timestamp | |
, -inputs.value as value | |
FROM `bigquery-public-data.crypto_bitcoin.inputs` as inputs | |
WHERE DATE(block_timestamp) >= '2011-1-1' and DATE(block_timestamp) <= '2014-1-1' | |
UNION ALL | |
-- credits | |
SELECT | |
array_to_string(outputs.addresses, ",") as address | |
, block_timestamp | |
, outputs.value as value | |
FROM `bigquery-public-data.crypto_bitcoin.outputs` as outputs | |
WHERE DATE(block_timestamp) >= '2011-1-1' and DATE(block_timestamp) <= '2014-1-1' | |
) | |
select address, sum(value)/100000000 as balance | |
from double_entry_book WHERE address LIKE '1%' | |
group by address | |
having balance>0.5 | |
order by balance desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment