1. The Group by clause and fill ()
In general, a group by interval uses a null output to represent data that has no value, and fill () can be used to change the output without a value. The Fill () option includes
- Any number
- NULL: Set NULL for output with no data within interval
- Previous: Copy the value of the previous interval as output without data
- None: Skip No value
The following example shows the use of fill ()
GROUP by without Fill ()
Example 1
SELECT MEAN(water_level) FROM h2o_feet WHERE time >= ‘2015-08-18‘ AND time < ‘2015-09-24‘ GROUP BY time(10d)
结果
name: h2o_feet--------------time mean2015-08-13T00:00:00Z 4.3062120833333232015-08-23T00:00:00Z 4.3189446293670292015-09-02T00:00:00Z 4.3638776812047812015-09-12T00:00:00Z 4.69811470811633?2015-09-22T00:00:00Z
GROUP BY with fill()
例子2
Use fill()
with -100
:
SELECT MEAN(water_level) FROM h2o_feet WHERE time >= ‘2015-08-18‘ AND time < ‘2015-09-24‘ GROUP BY time(10d) fill(-100)
结果
name: h2o_feet--------------time mean2015-08-13T00:00:00Z 4.3062120833333232015-08-23T00:00:00Z 4.3189446293670292015-09-02T00:00:00Z 4.3638776812047812015-09-12T00:00:00Z 4.698114708116322?2015-09-22T00:00:00Z -100
Example 3
Use fill()
with none
:
SELECT MEAN(water_level) FROM h2o_feet WHERE time >= ‘2015-08-18‘ AND time < ‘2015-09-24‘ GROUP BY time(10d) fill(none)
Results
name: h2o_feet--------------time mean2015-08-13T00:00:00Z 4.3062120833333232015-08-23T00:00:00Z 4.3189446293670292015-09-02T00:00:00Z 4.3638776812047812015-09-12T00:00:00Z 4.69811470811633?
Note: If you use Group (ing) by something (for example, have tags and a time interval), fill () must be placed at the end of group by.
InfluxDB---Data exploration