]> www.average.org Git - pulsecounter.git/blobdiff - select.sql
change scheme to use sum of adjustments
[pulsecounter.git] / select.sql
diff --git a/select.sql b/select.sql
new file mode 100644 (file)
index 0000000..88bcba4
--- /dev/null
@@ -0,0 +1,12 @@
+select to_seconds(timestamp) as time, value+adj as value from
+  (select c.timestamp timestamp, c.value value, 
+               (select sum(value) from coldadj a
+                       where a.timestamp <= c.timestamp
+               ) adj from coldcnt c order by timestamp
+  ) t;
+select to_seconds(timestamp) as time, value+adj as value from
+  (select c.timestamp timestamp, c.value value, 
+               (select sum(value) from hotadj a
+                       where a.timestamp <= c.timestamp
+               ) adj from hotcnt c order by timestamp
+  ) t;