Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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