SQL Query for NULL values .... take previous and next not NULL values ...
Hello,I have a table like this with NULL values as shown below
ID TS value
38 2014-03-13 10:00:10 47202.465
38 2014-03-13 11:00:10 47023.293
38 2014-03-13 12:00:10 48010.902
38 2014-03-13 13:00:10 NULL
38 2014-03-13 14:00:10 NULL
38 2014-03-13 15:00:10 46852.3
38 2014-03-13 16:00:10 NULL
38 2014-03-13 17:00:10 NULL
38 2014-03-13 18:00:10 NULL
38 2014-03-13 19:00:10 NULL
38 2014-03-13 20:00:10 47773.148
38 2014-03-13 21:00:10 47753.547
Can someone help me with the SQL query which will give Output as below, which is value before NULL and value after NULL and divide by 2.
For example, value for 2014-03-13 13:00:10 is (48010.902 + 46852.3)/2
ID TS value
38 2014-03-13 10:00:10 47202.465
38 2014-03-13 11:00:10 47023.293
38 2014-03-13 12:00:10 48010.902
38 2014-03-13 13:00:10 47431.601
38 2014-03-13 14:00:10 47141.9505
38 2014-03-13 15:00:10 46852.3
38 2014-03-13 16:00:10 47312.724
38 2014-03-13 17:00:10 47542.936
38 2014-03-13 18:00:10 47658.042
38 2014-03-13 19:00:10 47715.595
38 2014-03-13 20:00:10 47773.148
38 2014-03-13 21:00:10 47753.547
Thanks a lot