1) count () function
Returns the number of non-null values in an (field) field.
Grammar:
SELECT COUNT (<field_key>) from <measurement_name> [WHERE <stuff>] [GROUP by <stuff>]
Example:
>select COUNT (water_level) from H2o_feetname:h2o_feet--------------time count1970-01-01t00:0 0:00z 15258
Description Water_level This field has a total of 15,258 data in the H2o_feet table.
Note: If the function in Influxdb does not have a specified time, it will default to epoch 0 ( 1970-01-01T00:00:00Z
) as the time.
You can add a time condition to the where, as follows:
> select count (water_level) FROM h2o_feet WHERE time >= ' 2015-08-18t00:00:00z ' AND time < ' 2015-09-18t17:00:00z ' group by time (4d ) Name: h2o_feet--------------time count2015-08-17t00:0 0:00z 14402015-08-21t00:00:00z 19202015-08-25t00:0 0:00z 19202015-08-29t00:00:00z 19202015-09-02t00:0 0:00z 19152015-09-06t00:00:00z 19202015-09-10t00:0 0:00z 19202015-09-14t00:00:00z 19202015-09-18t00:0 0:00z 335
The result will contain the time result.
2) DISTINCT () function
Returns the unique value of a field.
Grammar:
SELECT DISTINCT (<field_key>) from <measurement_name> [WHERE <stuff>] [GROUP by <stuff>]
Using the example
> select distinct ("Level description") from h2o_feetname: h2o_ Feet--------------time distinct1970-01-01t00:00:00z between 6 and 9 feet1970-01-01T00:00:00Z below 3 feet1970-01-01t00:00:00z between 3 and 6 feet1970-01-01t00:00:00z at or greater than 9 feet
This example shows that level description has a total of four values, and then it is displayed with the default time.
3) MEAN () function
Returns the arithmetic mean (average) of a value in a field. The field type must be Long integer or float64.
Syntax format:
SELECT MEAN (<field_key>) from <measurement_name> [WHERE <stuff>] [GROUP by <stuff>]
Using the example
> SELECT MEAN (water_level) from H2o_feetname:h2o_feet--------------time mean1970-01-01t00:00 : 00Z 4.286791371454075
Indicates that the average value of the Water_level field is4.286791371454075
Time is the default time, of course, you can also join the Where condition.
4) MEDIAN () function
Returns the median (median) value from the sorted value in a single field. The type of the field value must be a long integer or float64 format.
Grammar:
SELECT MEDIAN (<field_key>) from <measurement_name> [WHERE <stuff>] [GROUP by <stuff>]
Using the example
> SELECT MEDIAN (water_level) from H2o_feetname:h2o_feet--------------time median1970-01-01t0 0:00:00z 4.124
The median number of water_level fields in the description table is 4.124
5) SPREAD () function
Returns the difference between the minimum and maximum values of a field. The type of the data must be long integer or float64.
Grammar:
SELECT SPREAD (<field_key>) from <measurement_name> [WHERE <stuff>] [GROUP by <stuff>]
Using the example
> SELECT SPREAD (water_level) from H2o_feetname:h2o_feet--------------time spread1970-01-01t 00:00:00z 10.574
6) SUM () function
Returns the and of all the values in a field. The type of the field must be long integer or float64.
Grammar:
SELECT SUM (<field_key>) from <measurement_name> [WHERE <stuff>] [GROUP by <stuff>]
Examples of Use:
> SELECT SUM (water_level) from H2o_feetname:h2o_feet--------------time sum1970-01-01t00:00:0 0Z 67777.66900000002
This statement calculates the and of all the Water_level fields in the H2o_feet table.
INFLUXDB+COLLECTD (3)--influxdb basic Operation 2