Baselight
Loading...Loading chart...
1WITH base_prices AS (
2    SELECT 
3        instrument,
4        close AS base_price
5    FROM "@coindesk.indices.coindesk_spot_price"
6    WHERE datetime = '2022-01-01'
7      AND instrument IN ('BTC-USD', 'ETH-USD', 'SOL-USD', 'XRP-USD', 'ADA-USD', 'AVAX-USD', 'MATIC-USD', 'DOT-USD')
8),
9latest_prices AS (
10    SELECT 
11        instrument,
12        close AS current_price,
13        datetime
14    FROM "@coindesk.indices.coindesk_spot_price"
15    WHERE datetime = (SELECT MAX(datetime) FROM "@coindesk.indices.coindesk_spot_price")
16      AND instrument IN ('BTC-USD', 'ETH-USD', 'SOL-USD', 'XRP-USD', 'ADA-USD', 'AVAX-USD', 'MATIC-USD', 'DOT-USD')
17)
18SELECT 
19    b.instrument,
20    ROUND(b.base_price, 2) AS price_jan_2022,
21    ROUND(l.current_price, 2) AS price_now,
22    ROUND((l.current_price / b.base_price - 1) * 100, 2) AS total_return_pct,
23    ROUND(1000 * (l.current_price / b.base_price), 2) AS value_of_1000_invested
24FROM base_prices b
25JOIN latest_prices l ON b.instrument = l.instrument
26ORDER BY total_return_pct DESC
instrumentprice_jan_2022price_nowtotal_return_pctvalue_of_1000_invested
XRP-USD0.852.53197.022970.18
BTC-USD47713.48110576.71131.752317.52
SOL-USD179.04188.195.111051.09
ETH-USD3766.793908.493.761037.62
ADA-USD1.380.61-55.69443.08
AVAX-USD114.2618.85-83.5164.96
DOT-USD28.612.99-89.55104.48
MATIC-USD2.580.19-92.4975.08

Share link

Anyone who has the link will be able to view this.