Skip to content

Instantly share code, notes, and snippets.

@peacing
Last active June 12, 2022 14:05
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/d578aa04e8fa1c85be3e795fa3ab56ad to your computer and use it in GitHub Desktop.
Save peacing/d578aa04e8fa1c85be3e795fa3ab56ad to your computer and use it in GitHub Desktop.
daily change of crypto prices
with yest AS (
SELECT currency, price
FROM f_crypto_prices
WHERE TRUNC(datetime, 'day') = '20220315')
, today AS (
SELECT currency, price
FROM f_crypto_prices
WHERE TRUNC(datetime, 'day') = '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