Skip to content

Instantly share code, notes, and snippets.

@peacing
Last active June 12, 2022 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peacing/04ded116f1a5a0d24b300270dc453811 to your computer and use it in GitHub Desktop.
Save peacing/04ded116f1a5a0d24b300270dc453811 to your computer and use it in GitHub Desktop.
with yest AS (
SELECT currency, price
FROM f_crypto_prices
WHERE datekey = '20220315')
, today AS (
SELECT currency, price
FROM f_crypto_prices
WHERE datekey = '20220316')
SELECT
currency,
(today.price - yest.price) / yest.price * 100 AS pct_change
FROM yest, today
WHERE currency = 'BTC'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment