From cb60101a35df0a462fc54dac56a93353b1359c3b Mon Sep 17 00:00:00 2001 From: yvesf Date: Sun, 17 Jul 2011 15:25:02 +0200 Subject: korrigiere populate_cache.sql --- populate_cache.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'populate_cache.sql') diff --git a/populate_cache.sql b/populate_cache.sql index 0c30a18..f13fa85 100644 --- a/populate_cache.sql +++ b/populate_cache.sql @@ -10,7 +10,7 @@ create or replace view vi_value_cache as SELECT timestamp, sensor_id, value_real, 'CACHE' FROM value_cache UNION - SELECT date_trunc('hour', timestamp), sensor_id, COALESCE(avg(value_int),avg(value_real)), 'LIVE' + SELECT date_trunc('hour', timestamp), sensor_id, COALESCE(avg(value_int),avg(value_float)), 'LIVE' FROM value WHERE date_trunc('hour', timestamp) > coalesce((select max(timestamp) from value_cache), now() - interval '2 days') @@ -35,7 +35,7 @@ BEGIN delete from value_cache where timestamp >= last_update; insert into value_cache - select COALESCE(avg(value_real),avg(value_int)), date_trunc('hour', timestamp), sensor_id + select COALESCE(avg(value_float),avg(value_int)), date_trunc('hour', timestamp), sensor_id from value where date_trunc('hour', timestamp) > last_update group by date_trunc('hour', timestamp), sensor_id; -- cgit v1.2.1