Query editor
withmatic_prices as(selectdate_trunc('day', minute) as time,avg(price) as matic_pricefrom prices.usdwhere symbol = 'MATIC'and blockchain is nulland minute >= date_trunc('{{granularity}}',now()) - interval '{{period}}' daygroup by 1order by 1 desc),start_price as(selectmatic_price as matic_start_pricefrom matic_pricesorder by time asclimit 1)selecttime,matic_price,100*(matic_price - lag(matic_price,1) over (order by time))/ (lag(matic_price,1) over (order by time)) as pct_price,(matic_price - matic_start_price)/ (matic_start_price) as pct_start_price,avg(matic_price) over (order by time rows between 30 preceding and 0 following) as "ma(30) matic price",avg(matic_price) over (order by time rows between 14 preceding and 0 following) as "ma(14) matic price"from matic_prices, start_priceorder by time desc