diff --git a/sql/condition-glucose-grafana.sql b/sql/condition-glucose-grafana.sql index d897299..10b9053 100644 --- a/sql/condition-glucose-grafana.sql +++ b/sql/condition-glucose-grafana.sql @@ -43,5 +43,9 @@ SELECT time, smoothval, absvalue, FROM firstorder) SELECT *, ema(delta1st, 0.25) OVER (ORDER BY time ASC) as smoothdelta1st, - ema(delta2nd, 0.25) OVER (ORDER BY time ASC) as smoothdelta2nd + ema(delta2nd, 0.25) OVER (ORDER BY time ASC) as smoothdelta2nd, + STDDEV(delta1st) OVER ( + ORDER BY time + RANGE BETWEEN INTERVAL '6 hours' PRECEDING AND CURRENT ROW + ) AS std_dev_delta1st FROM secondorder;