Query editor
WITH BTC AS(selectavg(price) as usd_btc,date_trunc('day',minute) as daysfrom prices.usdwhere contract_address is null and symbol='BTC'and minute>=date_trunc('hour',now()-interval '730' day)group by date_trunc('day',minute)order by date_trunc('day',minute)),SOL AS (selectavg(price) as USD_SOL,date_trunc('day',minute) as daysfrom prices.usdwhere contract_address is null and symbol='SOL'and minute>=date_trunc('hour',now()-interval '730' day)group by date_trunc('day',minute)order by date_trunc('day',minute)),ETH AS (selectavg(price) as USD_ETH,date_trunc('day',minute) as daysfrom prices.usdwhere contract_address is null and symbol='ETH'and minute>=date_trunc('hour',now()-interval '730' day)group by date_trunc('day',minute)order by date_trunc('day',minute)),combined as (SELECT A.DAYS,A.USD_BTC,B.USD_SOL,C.USD_ETHFROM BTC ALEFT JOIN SOL B ON A.DAYS = B.DAYSLEFT JOIN ETH C ON A.DAYS = C.DAYSORDER BY A.DAYS),summary as (select days,--USD_BTC,--USD_ETH,--USD_SOL,-- (USD_BTC - LAG(USD_BTC, 1) OVER (ORDER BY days)) / CAST(LAG(USD_BTC, 1) OVER (ORDER BY days) AS DOUBLE) AS Delta_BTC(USD_ETH - LAG(USD_ETH, 1) OVER (ORDER BY days)) / CAST(LAG(USD_ETH, 1) OVER (ORDER BY days) AS DOUBLE) AS Delta_ETH-- (USD_SOL - LAG(USD_SOL, 1) OVER (ORDER BY days)) / CAST(LAG(USD_SOL, 1) OVER (ORDER BY days) AS DOUBLE) AS Delta_SOLfrom combinedorder by days)selectcasewhen Delta_ETH between -3 and -.91 then 'A.>=-91%'when Delta_ETH between -.9 and -.2 then 'B.>=-20%'when Delta_ETH between -.19 and -.15 then 'C.15-19%'when Delta_ETH between -.14 and -.1 then 'D.-10-14%'when Delta_ETH between -.09 and -.05 then 'E.-5-9%'when Delta_ETH between -.04 and -.0000001 then 'F.-4-0%'when Delta_ETH between 0 and .05 then 'G.0-4%'when Delta_ETH between .06 and .1 then 'H.6-10%'