标签:-bash 4.6 from 跳过 lang xpl evel nbsp name
1、The Group by clause and fill()
一般情况下,一个group by 间隔时间用null输出代表没有值的数据,可用fill()来改变没有值 的输出方式。fill()选项包括
以下的例子可以看出fill()的用法
GROUP BY without fill()
例子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 mean
2015-08-13T00:00:00Z 4.306212083333323
2015-08-23T00:00:00Z 4.318944629367029
2015-09-02T00:00:00Z 4.363877681204781
2015-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 mean 2015-08-13T00:00:00Z 4.306212083333323 2015-08-23T00:00:00Z 4.318944629367029 2015-09-02T00:00:00Z 4.363877681204781 2015-09-12T00:00:00Z 4.698114708116322 ?2015-09-22T00:00:00Z -100
例子3
Usefill()
withnone
:
SELECT MEAN(water_level) FROM h2o_feet WHERE time >= ‘2015-08-18‘ AND time < ‘2015-09-24‘ GROUP BY time(10d) fill(none)
结果
name: h2o_feet -------------- time mean 2015-08-13T00:00:00Z 4.306212083333323 2015-08-23T00:00:00Z 4.318944629367029 2015-09-02T00:00:00Z 4.363877681204781 2015-09-12T00:00:00Z 4.69811470811633 ?
注意:如果你用GROUP(ing) BY一些东西(如,有tags和一上时间间隔),fill()必须放在group by 的最后。
标签:-bash 4.6 from 跳过 lang xpl evel nbsp name
原文地址:http://www.cnblogs.com/michellexiaoqi/p/7297489.html