superman
superman

Reputation: 1

How to fill a preceding non-null value when using time window in TDengine?

I have a SQL statement that counts every second of status in TDengine.

SELECT 
  first(ts), 
  voltage 
FROM 
  d1 
where 
  ts >= '2017-07-14 10:40:00.000' 
  AND ts <= '2017-07-14 10:41:00.066' INTERVAL(1s)

There are 3 seconds of data that are missing, as shown in the figure.

enter image description here

If there is no value, I would like to use a previous non-null value in the query instead. So I tried to add a FILL(PREV);. However, the result doesn't look right.

enter image description here

How do I modify this statement?

Upvotes: 0

Views: 57

Answers (1)

cpvmrd
cpvmrd

Reputation: 41

Maybe you can try this:

SELECT 
  _wstart, 
  first(voltage) 
FROM 
  d1 
where 
  ts >= '2017-07-14 10:40:00.000' 
  AND ts <= '2017-07-14 10:41:00.066'
  INTERVAL(1s) FILL(PREV)

Upvotes: 0

Related Questions