Query editor
with eth_monthly_price as(selectminute,price,min(minute) over(partition by date_trunc('month',minute)) as month_first_day,max(minute) over(partition by date_trunc('month',minute)) as month_last_dayfromprices.usdwhereblockchain is nulland contract_address is nulland symbol = 'ETH'),eth_monthly_price_lead as(selectminute,price,lead(price)over(partition by date_trunc('month',minute) order by minute) as lead_price,month_first_day,month_last_dayfrom eth_monthly_price where minute = month_first_day or minute = month_last_dayorder by minute),-- select-- year(minute) as year,-- -- date_trunc('month',minute) as month,-- month(minute) as month,-- (lead_price - price)/price as rate-- from eth_monthly_price_lead where lead_price is not null-- order by 1,2eth_monthly_price_tmp as(selectyear(minute) as year,-- date_trunc('month',minute) as month,month(minute) as month,case when month(minute) = 1 then (lead_price - price)/price end as m1,case when month(minute) = 2 then (lead_price - price)/price end as m2,case when month(minute) = 3 then (lead_price - price)/price end as m3,case when month(minute) = 4 then (lead_price - price)/price end as m4,case when month(minute) = 5 then (lead_price - price)/price end as m5,case when month(minute) = 6 then (lead_price - price)/price end as m6,case when month(minute) = 7 then (lead_price - price)/price end as m7,case when month(minute) = 8 then (lead_price - price)/price end as m8,case when month(minute) = 9 then (lead_price - price)/price end as m9,case when month(minute) = 10 then (lead_price - price)/price end as m10,case when month(minute) = 11 then (lead_price - price)/price end as m11,case when month(minute) = 12 then (lead_price - price)/price end as m12from eth_monthly_price_lead where lead_price is not nullorder by 1,2)selectyear,min(m1) as m1,min(m2) as m2,min(m3) as m3,min(m4) as m4,min(m5) as m5,min(m6) as m6,min(m7) as m7,