Skip to content

Instantly share code, notes, and snippets.

@YazzyYaz
Last active December 27, 2019 13:58
Show Gist options
  • Select an option

  • Save YazzyYaz/eea7bd2d9b1c00cb5ce04830014c5137 to your computer and use it in GitHub Desktop.

Select an option

Save YazzyYaz/eea7bd2d9b1c00cb5ce04830014c5137 to your computer and use it in GitHub Desktop.
ETC/ETH Daily Gas Usage Total
WITH ethereum_total_gas as (
SELECT SUM(gas_used) as eth_sum_gas,
TIMESTAMP_TRUNC(timestamp, DAY) as eth_date,
FROM `bigquery-public-data.crypto_ethereum.blocks`
GROUP BY eth_date),
etc_total_gas as (
SELECT SUM(gas_used) as etc_sum_gas,
TIMESTAMP_TRUNC(timestamp, DAY) as etc_date,
FROM `bigquery-public-data.crypto_ethereum_classic.blocks`
GROUP BY etc_date
),
total_transactions_book AS (
SELECT *
FROM ethereum_total_gas eth
LEFT JOIN etc_total_gas etc ON eth.eth_date = etc.etc_date
)
SELECT etc_date as date,
etc_sum_gas AS ETC,
eth_sum_gas AS ETH,
FROM total_transactions_book
ORDER by etc_date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment