InfluxQL transformation functions
InfluxQL transformation functions modify and return values each row of queried data.
Each transformation function below covers syntax, including parameters to pass to the function, and examples of how to use the function. Examples use NOAA water sample data and data from sample_test.txt.
- ABS()
- ACOS()
- ASIN()
- ATAN()
- ATAN2()
- CEIL()
- COS()
- CUMULATIVE_SUM()
- DERIVATIVE()
- DIFFERENCE()
- ELAPSED()
- EXP()
- FLOOR()
- HISTOGRAM()
- LN()
- LOG()
- LOG2()
- LOG10()
- MOVING_AVERAGE()
- NON_NEGATIVE_DERIVATIVE()
- NON_NEGATIVE_DIFFERENCE
- POW
- ROUND
- SIN
- SQRT
- TAN
ABS()
Returns the absolute value of the field value. Supports GROUP BY clauses that group by tags but not group by time.
Basic syntax
1. SELECT ABS( [ * | <field_key> ] ) FROM_clause [WHERE_clause] [GROUP_BY_clause] [ORDER_BY_clause] [LIMIT_clause] [OFFSET_clause] [SLIMIT_clause] [SOFFSET_clause]
ABS(field_key)
Returns the absolute values of field values associated with the field key.
ABS(*)
Returns the absolute values of field values associated with each field key in the measurement.
ABS() supports int64 and float64 field value data types.
Examples
Calculate the absolute values of field values associated with a field key
Return the absolute values of field values in the water_level field key in the h2o_feet measurement.
1. SELECT ABS("water_level") FROM "h2o_feet" WHERE time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:15:00Z'
name: data
| time | abs |
|---|---|
| 2019-08-18T00:00:00Z | 8.5040000000 |
| 2019-08-18T00:00:00Z | 2.3520000000 |
| 2019-08-18T00:06:00Z | 8.4190000000 |
| 2019-08-18T00:06:00Z | 2.3790000000 |
| 2019-08-18T00:12:00Z | 8.3200000000 |
| 2019-08-18T00:12:00Z | 2.3430000000 |
Calculate the absolute values of field values associated with each field key in a measurement
Return the absolute values of field values for each field key that stores numeric values in the data measurement. The h2o_feet measurement has one numeric field water_level.
1. SELECT ABS(*) FROM "h2o_feet" WHERE time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:15:00Z'
name: data
| time | abs_water_level |
|---|---|
| 2019-08-18T00:00:00Z | 8.5040000000 |
| 2019-08-18T00:00:00Z | 2.3520000000 |
| 2019-08-18T00:06:00Z | 8.4190000000 |
| 2019-08-18T00:06:00Z | 2.3790000000 |
| 2019-08-18T00:12:00Z | 8.3200000000 |
| 2019-08-18T00:12:00Z | 2.3430000000 |
Calculate the absolute values of field values associated with a field key and include several clauses
Return the absolute values of field values associated with the water_level field key in the time range between 2019-08-18T00:00:00Z and 2019-08-18T00:30:00Z with results in descending timestamp order. The query also limits the number of points returned to four and offsets results by two points.
1. SELECT ABS("water_level") FROM "h2o_feet" WHERE time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:30:00Z' ORDER BY time DESC LIMIT 4 OFFSET 2
name: data
| time | abs |
|---|---|
| 2019-08-18T00:24:00Z | 2.2640000000 |
| 2019-08-18T00:24:00Z | 8.1300000000 |
| 2019-08-18T00:18:00Z | 2.3290000000 |
| 2019-08-18T00:18:00Z | 8.2250000000 |
Advanced syntax
1. SELECT ABS(<function>( [ * | <field_key> ] )) FROM_clause [WHERE_clause] GROUP_BY_clause [ORDER_BY_clause] [LIMIT_clause] [OFFSET_clause] [SLIMIT_clause] [SOFFSET_clause]
The advanced syntax requires a GROUP BY time() clause and a nested InfluxQL function. The query first calculates the results for the nested function at the specified GROUP BY time() interval and then applies the ABS() function to those results.
ABS() supports the following nested functions:
COUNT(), MEAN(), MEDIAN(), MODE(), SUM(), FIRST(), LAST(), MIN(), MAX(), and PERCENTILE().
Examples
Calculate the absolute values of mean values
Return the absolute values of mean water_levels that are calculated at 12-minute intervals.
1. SELECT ABS(MEAN("water_level")) FROM "h2o_feet" WHERE time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:30:00Z' GROUP BY time(12m)
name: data
| time | abs |
|---|---|
| 2019-08-18T00:00:00Z | 5.4135000000 |
| 2019-08-18T00:12:00Z | 5.3042500000 |
| 2019-08-18T00:24:00Z | 5.1682500000 |
ACOS()
Returns the arccosine (in radians) of the field value. Field values must be between -1 and 1. Supports GROUP BY clauses that group by tags but does not support group by time.
Basic syntax
1. SELECT ACOS( [ * | <field_key> ] ) FROM_clause [WHERE_clause] [GROUP_BY_clause] [ORDER_BY_clause] [LIMIT_clause] [OFFSET_clause] [SLIMIT_clause] [SOFFSET_clause]
ACOS(field_key)
Returns the arccosine of field values associated with the field key.
ACOS(*)
Returns the arccosine of field values associated with each field key in the measurement.
ACOS() supports int64 and float64 field value data types with values between -1 and 1.
Examples
The examples below use a subset of data from sample_test.txt, which only includes field values within the calculable range (-1 to 1). This value range is required for the ACOS() function:
| time | a |
|---|---|
| 2018-06-24T12:01:00Z | -0.774984088561186 |
| 2018-06-24T12:02:00Z | -0.921037167720451 |
| 2018-06-24T12:04:00Z | -0.905980032168252 |
| 2018-06-24T12:05:00Z | -0.891164752631417 |
| 2018-06-24T12:09:00Z | 0.416579917279588 |
| 2018-06-24T12:10:00Z | 0.328968116955350 |
| 2018-06-24T12:11:00Z | 0.263585064411983 |
Calculate the arccosine of field values associated with a field key
Return the arccosine of field values in the a field key in the data measurement.
1. SELECT ACOS("a") FROM "data" WHERE time >= '2018-06-24T00:00:00Z' AND time <= '2018-06-25T00:00:00Z'
name: data
| time | acos |
|---|---|
| 2018-06-24T12:00:00Z | |
| 2018-06-24T12:01:00Z | 2.4574862443 |
| 2018-06-24T12:02:00Z | 2.7415314737 |
| 2018-06-24T12:03:00Z | |
| 2018-06-24T12:04:00Z | 2.7044854503 |
| 2018-06-24T12:05:00Z | 2.6707024029 |
| 2018-06-24T12:06:00Z | |
| 2018-06-24T12:07:00Z | |
| 2018-06-24T12:08:00Z | |
| 2018-06-24T12:09:00Z | 1.1411163210 |
| 2018-06-24T12:10:00Z | 1.2355856616 |
| 2018-06-24T12:11:00Z | 1.3040595066 |
Calculate the arccosine of field values associated with each field key in a measurement
Return the arccosine of field values for each field key that stores numeric values in the data measurement, field a and b.
1. SELECT ACOS(*) FROM "data" WHERE time >= '2018-06-24T00:00:00Z' AND time <= '2018-06-25T00:00:00Z'
name: data
| time | acos_a | acos_b |
|---|---|---|
| 2018-06-24T12:00:00Z | 1.7351786976 | |
| 2018-06-24T12:01:00Z | 2.4574862443 | 1.4333294161 |
| 2018-06-24T12:02:00Z | 2.7415314737 | 2.0748091141 |
| 2018-06-24T12:03:00Z | 1.6438345404 | |
| 2018-06-24T12:04:00Z | 2.7044854503 | |
| 2018-06-24T12:05:00Z | 2.6707024029 | 0.7360183965 |
| 2018-06-24T12:06:00Z | 1.2789990384 | |
| 2018-06-24T12:07:00Z | 2.1522589654 | |
| 2018-06-24T12:08:00Z | 0.6128438977 | |
| 2018-06-24T12:09:00Z | 1.1411163210 | |
| 2018-06-24T12:10:00Z | 1.2355856616 | |
| 2018-06-24T12:11:00Z | 1.3040595066 | 1.7595349692 |
| 2018-06-24T12:12:00Z | 1.8681669412 | 2.5213034266 |
Calculate the arccosine of field values associated with a field key and include several clauses
Return the arccosine of field values associated with the a field key in the time range between 2018-06-24T00:00:00Z and 2018-06-25T00:00:00Z with results in descending timestamp order. The query also limits the number of points returned to four and offsets results by two points.
1. SELECT ACOS("a") FROM "data" WHERE time >= '2018-06-24T00:00:00Z' AND time <= '2018-06-25T00:00:00Z' ORDER BY time DESC LIMIT 4 OFFSET 2
name: data
| time | acos |
|---|---|
| 2018-06-24T23:58:00Z | 1.5361053361 |
| 2018-06-24T23:57:00Z | |
| 2018-06-24T23:56:00Z | 0.5211076815 |
| 2018-06-24T23:55:00Z | 1.647695085 |
Advanced syntax
1. SELECT ACOS(<function>( [ * | <field_key> ] )) FROM_clause [WHERE_clause] GROUP_BY_clause [ORDER_BY_clause] [LIMIT_clause] [OFFSET_clause] [SLIMIT_clause] [SOFFSET_clause]
The advanced syntax requires a GROUP BY time() clause and a nested InfluxQL function. The query first calculates the results for the nested function at the specified GROUP BY time() interval and then applies the ACOS() function to those results.
ACOS() supports the following nested functions: COUNT(), MEAN(), MEDIAN(), MODE(), SUM(), FIRST(), LAST(), MIN(), MAX(), and PERCENTILE().
Examples
Calculate the arccosine of mean values
Return the arccosine of mean a that are calculated at 3 hour intervals.
1. SELECT ACOS(MEAN("a")) FROM "data" WHERE time >= '2018-06-24T00:00:00Z' AND time <= '2018-06-25T00:00:00Z' GROUP BY time(3h)
name: data
| time | acos |
|---|---|
| 2018-06-24T00:00:00Z | |
| 2018-06-24T03:00:00Z | |
| 2018-06-24T06:00:00Z | |
| 2018-06-24T09:00:00Z | |
| 2018-06-24T12:00:00Z | 1.5651603194 |
| 2018-06-24T15:00:00Z | 1.6489104619 |
| 2018-06-24T18:00:00Z | 1.4851295699 |
| 2018-06-24T21:00:00Z | 1.6209901549 |
| 2018-06-25T00:00:00Z | 1.7149309371 |
ASIN()
Returns the arcsine (in radians) of the field value. Field values must be between -1 and 1.
Basic syntax
1. SELECT ASIN( [ * | <field_key> ] ) FROM_clause [WHERE_clause] [GROUP_BY_clause] [ORDER_BY_clause] [LIMIT_clause] [OFFSET_clause] [SLIMIT_clause] [SOFFSET_clause]
ASIN(field_key)
Returns the arcsine of field values associated with the field key.
ASIN(*)
Returns the arcsine of field values associated with each field key in the measurement.
ASIN() supports int64 and float64 field value data types with values between -1 and 1.
Supports GROUP BY clauses that group by tags but not GROUP BY clauses that group by time. To use ASIN() with a GROUP BY time() clause, see Advanced syntax.
Examples
The examples below use the following data from sample_test.txt.
The following data from this data set only includes field value within the calculable range (-1 to 1) required for the ASIN() function:
| time | a |
|---|---|
| 2018-06-24T12:01:00Z | -0.774984088561186 |
| 2018-06-24T12:02:00Z | -0.921037167720451 |
| 2018-06-24T12:04:00Z | -0.905980032168252 |
| 2018-06-24T12:05:00Z | -0.891164752631417 |
| 2018-06-24T12:09:00Z | 0.416579917279588 |
| 2018-06-24T12:10:00Z | 0.328968116955350 |
| 2018-06-24T12:11:00Z | 0.263585064411983 |
Calculate the arcsine of field values associated with a field key
Return the arcsine of field values in the a field key in the data measurement.
1. SELECT ASIN("a") FROM "data" WHERE time >= '2018-06-24T00:00:00Z' AND time <= '2018-06-25T00:00:00Z'
name: data
| time | asin |
|---|---|
| 2018-06-24T12:00:00Z | |
| 2018-06-24T12:01:00Z | -0.8866899175 |
| 2018-06-24T12:02:00Z | -1.1707351469 |
| 2018-06-24T12:03:00Z | |
| 2018-06-24T12:04:00Z | -1.1336891235 |
| 2018-06-24T12:05:00Z | -1.0999060761 |
| 2018-06-24T12:06:00Z | |
| 2018-06-24T12:07:00Z | |
| 2018-06-24T12:08:00Z | |
| 2018-06-24T12:09:00Z | 0.4296800058 |
| 2018-06-24T12:10:00Z | 0.3352106652 |
| 2018-06-24T12:11:00Z | 0.2667368202 |
| 2018-06-24T12:12:00Z | -0.2973706144 |
Calculate the arcsine of field values associated with each field key in a measurement
Return the arcsine of field values for each field key that stores numeric values in the data measurement. The data measurement has one numeric field: a.
1. SELECT ASIN(*) FROM "data" WHERE time >= '2018-06-24T00:00:00Z' AND time <= '2018-06-25T00:00:00Z'
name: data
| time | asin_a | asin_b |
|---|---|---|
| 2018-06-24T12:00:00Z | -0.1643823708 | |
| 2018-06-24T12:01:00Z | -0.8866899175 | 0.1374669107 |
| 2018-06-24T12:02:00Z | -1.1707351469 | -0.5040127873 |
| 2018-06-24T12:03:00Z | -0.0730382136 | |
| 2018-06-24T12:04:00Z | -1.1336891235 | |
| 2018-06-24T12:05:00Z | -1.0999060761 | 0.8347779303 |
| 2018-06-24T12:06:00Z | 0.2917972884 | |
| 2018-06-24T12:07:00Z | -0.5814626386 | |
| 2018-06-24T12:08:00Z | 0.9579524291 | |
| 2018-06-24T12:09:00Z | 0.4296800058 | |
| 2018-06-24T12:10:00Z | 0.3352106652 | |
| 2018-06-24T12:11:00Z | 0.2667368202 | -0.1887386424 |
| 2018-06-24T12:12:00Z | -0.2973706144 | -0.9505070998 |
Calculate the arcsine of field values associated with a field key and include several clauses
Return the arcsine of field values associated with the a field key in the time range between 2018-06-24T00:00:00Z and 2018-06-25T00:00:00Z with results in descending timestamp order. The query also limits the number of points returned to four and offsets results by two points.
1. SELECT ASIN("a") FROM "data" WHERE time >= '2018-06-24T00:00:00Z' AND time <= '2018-06-25T00:00:00Z' ORDER BY time DESC LIMIT 4 OFFSET 2
name: data
| time | asin |
|---|---|
| 2018-06-24T23:58:00Z | 0.0346909907 |
| 2018-06-24T23:57:00Z | |
| 2018-06-24T23:56:00Z | 1.0496886453 |
| 2018-06-24T23:55:00Z | 0.0768987583 |
Advanced syntax
1. SELECT ASIN(<function>( [ * | <field_key> ] )) FROM_clause [WHERE_clause] GROUP_BY_clause [ORDER_BY_clause] [LIMIT_clause] [OFFSET_clause] [SLIMIT_clause] [SOFFSET_clause]
The advanced syntax requires a GROUP BY time() clause and a nested InfluxQL function. The query first calculates the results for the nested function at the specified GROUP BY time() interval and then applies the ASIN() function to those results.
ASIN() supports the following nested functions: COUNT(), MEAN(), MEDIAN(), MODE(), SUM(), FIRST(), LAST(), MIN(), MAX(), and PERCENTILE().
Examples
Calculate the arcsine of mean values
Return the arcsine of mean as that are calculated at 3-hour intervals.
1. SELECT ASIN(MEAN("a")) FROM "data" WHERE time >= '2018-06-24T00:00:00Z' AND time <= '2018-06-25T00:00:00Z' GROUP BY time(3h)
name: data
| time | asin |
|---|---|
| 2018-06-24T00:00:00Z | |
| 2018-06-24T03:00:00Z | |
| 2018-06-24T06:00:00Z | |
| 2018-06-24T09:00:00Z | |
| 2018-06-24T12:00:00Z | 0.0056360073 |
| 2018-06-24T15:00:00Z | -0.0781141351 |
| 2018-06-24T18:00:00Z | 0.0856667569 |
| 2018-06-24T21:00:00Z | -0.0501938281 |
| 2018-06-25T00:00:00Z | -0.1441346103 |
ATAN()
Returns the arctangent (in radians) of the field value. Field values must be between -1 and 1.
Supports GROUP BY clauses that group by tags but not GROUP BY clauses that group by time. To use ATAN() with a GROUP BY time() clause, see the Advanced syntax.
Basic syntax
1. SELECT ATAN( [ * | <field_key> ] ) FROM_clause [WHERE_clause] [GROUP_BY_clause] [ORDER_BY_clause] [LIMIT_clause] [OFFSET_clause] [SLIMIT_clause] [SOFFSET_clause]
ATAN(field_key)
Returns the arctangent of field values associated with the field key.
ATAN(*)
Returns the arctangent of field values associated with each field key in the measurement.
ATAN() supports int64 and float64 field value data types with values between -1 and 1.
Examples
The examples below use a subset of data from sample_test.txt that only includes field values within the calculable range (-1 to 1) required for the of the ATAN() function.
Calculate the arctangent of field values associated with a field key
Return the arctangent of field values in the a field key in the data measurement.
1. SELECT ATAN("a") FROM "data" WHERE time >= '2018-06-24T00:00:00Z' AND time <= '2018-06-25T00:00:00Z'
name: data
| time | atan |
|---|---|
| 2018-06-24T12:00:00Z | 0.9293622934 |
| 2018-06-24T12:01:00Z | -0.6593001275 |
| 2018-06-24T12:02:00Z | -0.7443170184 |
| 2018-06-24T12:03:00Z | -1.0488818071 |
| 2018-06-24T12:04:00Z | -0.7361091801 |
| 2018-06-24T12:05:00Z | -0.7279122495 |
| 2018-06-24T12:06:00Z | 0.8379907133 |
| 2018-06-24T12:07:00Z | -0.9117032768 |
| 2018-06-24T12:08:00Z | -1.0364006848 |
| 2018-06-24T12:09:00Z | 0.3947172008 |
| 2018-06-24T12:10:00Z | 0.3178167283 |
| 2018-06-24T12:11:00Z | 0.2577231762 |
| 2018-06-24T12:12:00Z | -0.2850291359 |
Calculate the arctangent of field values associated with each field key in a measurement
Return the arctangent of field values for each field key that stores numeric values in the data measurement–fields a and b.
1. SELECT ATAN(*) FROM "data" WHERE time >= '2018-06-24T00:00:00Z' AND time <= '2018-06-25T00:00:00Z'
name: data
| time | atan_a | atan_b |
|---|---|---|
| 2018-06-24T12:00:00Z | 0.9293622934 | -0.1622053541 |
| 2018-06-24T12:01:00Z | -0.6593001275 | 0.1361861379 |
| 2018-06-24T12:02:00Z | -0.7443170184 | -0.4499093122 |
| 2018-06-24T12:03:00Z | -1.0488818071 | -0.0728441751 |
| 2018-06-24T12:04:00Z | -0.7361091801 | 1.0585985451 |
| 2018-06-24T12:05:00Z | -0.7279122495 | 0.6378113578 |
| 2018-06-24T12:06:00Z | 0.8379907133 | 0.2801105336 |
| 2018-06-24T12:07:00Z | -0.9117032768 | -0.5022647489 |
| 2018-06-24T12:08:00Z | -1.0364006848 | 0.6856298940 |
| 2018-06-24T12:09:00Z | 0.3947172008 | -0.8711781065 |
| 2018-06-24T12:10:00Z | 0.3178167283 | -0.8273348593 |
| 2018-06-24T12:11:00Z | 0.2577231762 | -0.1854639556 |
| 2018-06-24T12:12:00Z | -0.2850291359 | -0.6830451940 |
Calculate the arctangent of field values associated with a field key and include several clauses
Return the arctangent of field values associated with the a field key in time range between 2017-05-01T00:00:00Z and 2017-05-09T00:00:00Z and returns results in descending timestamp order. The query also limits the number of points returned to four and offsets results by two points.
1. SELECT ATAN("a") FROM "data" WHERE time >= '2018-06-24T00:00:00Z' AND time <= '2018-06-25T00:00:00Z' ORDER BY time DESC LIMIT 4 OFFSET 2
name: data
| time | atan |
|---|---|
| 2018-06-24T23:58:00Z | 0.0346701348 |
| 2018-06-24T23:57:00Z | -0.8582372146 |
| 2018-06-24T23:56:00Z | 0.7144341473 |
| 2018-06-24T23:55:00Z | -0.0766723939 |
Advanced syntax
1. SELECT ATAN(<function>( [ * | <field_key> ] )) FROM_clause [WHERE_clause] GROUP_BY_clause [ORDER_BY_clause] [LIMIT_clause] [OFFSET_clause] [SLIMIT_clause] [SOFFSET_clause]
The advanced syntax requires a GROUP BY time() clause and a nested InfluxQL function. The query first calculates the results for the nested function at the specified GROUP BY time() interval and then applies the ATAN() function to those results.
ATAN() supports the following nested functions: COUNT(), MEAN(), MEDIAN(), MODE(), SUM(), FIRST(), LAST(), MIN(), MAX(), and PERCENTILE().
Examples of advanced syntax
Calculate the arctangent of mean values
Return the arctangent of mean as that are calculated at 3-hour intervals.
1. SELECT ATAN(MEAN("a")) FROM "data" WHERE time >= '2018-06-24T00:00:00Z' AND time <= '2018-06-25T00:00:00Z' GROUP BY time(3h)
name: data
| time | atan |
|---|---|
| 2018-06-24T00:00:00Z | |
| 2018-06-24T03:00:00Z | |
| 2018-06-24T06:00:00Z | |
| 2018-06-24T09:00:00Z | |
| 2018-06-24T12:00:00Z | 0.0056359178 |
| 2018-06-24T15:00:00Z | -0.0778769005 |
| 2018-06-24T18:00:00Z | 0.0853541301 |
| 2018-06-24T21:00:00Z | -0.0501307176 |
| 2018-06-25T00:00:00Z | -0.1426603174 |
ATAN2()
Returns the the arctangent of y/x in radians.
Basic syntax
1. SELECT ATAN2( [ * | <field_key> | num ], [ <field_key> | num ] ) FROM_clause [WHERE_clause] [GROUP_BY_clause] [ORDER_BY_clause] [LIMIT_clause] [OFFSET_clause] [SLIMIT_clause] [SOFFSET_clause]
ATAN2(field_key_y, field_key_x)
Returns the arctangent of field values associated with the field key, field_key_y, divided by field values associated with field_key_x.
ATAN2(*, field_key_x)
Returns the field values associated with each field key in the measurement divided by field values associated with field_key_x.
ATAN2() supports int64 and float64 field value data types.
Supports GROUP BY clauses that group by tags but not GROUP BY clauses that group by time. To use ATAN2() with a GROUP BY time() clause, see Advanced syntax.
Examples
The examples below use sample_test.txt.
Calculate the arctangent of field_key_b over field_key_a
Return the arctangents of field values in the a field key divided by values in the b field key. Both are part of the data measurement.
1. SELECT ATAN2("a", "b") FROM "data" WHERE time >= '2018-06-24T00:00:00Z' AND time <= '2018-06-25T00:00:00Z'
name: data
| time | atan2 |
|---|---|
| 2018-06-24T12:00:00Z | 1.6923979639 |
| 2018-06-24T12:01:00Z | -1.3957831900 |
| 2018-06-24T12:02:00Z | -2.0537314089 |
| 2018-06-24T12:03:00Z | -1.6127391493 |
| 2018-06-24T12:04:00Z | -0.4711275404 |
| 2018-06-24T12:05:00Z | -0.8770454978 |
| 2018-06-24T12:06:00Z | 1.3174573347 |
| 2018-06-24T12:07:00Z | -1.9730696643 |
| 2018-06-24T12:08:00Z | -1.1199236554 |
| 2018-06-24T12:09:00Z | 2.8043757212 |
| 2018-06-24T12:10:00Z | 2.8478694533 |
| 2018-06-24T12:11:00Z | 2.1893985296 |
| 2018-06-24T12:12:00Z | -2.7959592806 |
Calculate the arctangent of values associated with each field key in a measurement divided by field_key_a
Return the arctangents of all numeric field values in the data measurement divided by values in the a field key. The data measurement has two numeric fields: a and b.
1. SELECT ATAN2(*, "a") FROM "data" WHERE time >= '2018-06-24T00:00:00Z' AND time <= '2018-06-25T00:00:00Z'
name: data
| time | atan2_a | atan2_b |
|---|---|---|
| 2018-06-24T12:00:00Z | 0.7853981634 | -0.1216016371 |
| 2018-06-24T12:01:00Z | -2.3561944902 | 2.9665795168 |
| 2018-06-24T12:02:00Z | -2.3561944902 | -2.6586575715 |
| 2018-06-24T12:03:00Z | -2.3561944902 | -3.0996498311 |
| 2018-06-24T12:04:00Z | -2.3561944902 | 2.0419238672 |
| 2018-06-24T12:05:00Z | -2.3561944902 | 2.4478418246 |
| 2018-06-24T12:06:00Z | 0.7853981634 | 0.2533389921 |
| 2018-06-24T12:07:00Z | -2.3561944902 | -2.7393193161 |
| 2018-06-24T12:08:00Z | -2.3561944902 | 2.6907199822 |
| 2018-06-24T12:09:00Z | 0.7853981634 | -1.2335793944 |
| 2018-06-24T12:10:00Z | 0.7853981634 | -1.2770731265 |
| 2018-06-24T12:11:00Z | 0.7853981634 | -0.6186022028 |
| 2018-06-24T12:12:00Z | -2.3561944902 | -1.9164296997 |
Calculate the arctangents of field values and include several clauses
Return the arctangent of field values associated with the a field key divided by the b field key in the time range between 2018-05-16T12:10:00Z and 2018-05-16T12:10:00Z with results in descending timestamp order. The query also limits the number of points returned to four and offsets results by two points.
1. SELECT ATAN2("a", "b") FROM "data" WHERE time >= '2018-06-24T00:00:00Z' AND time <= '2018-06-25T00:00:00Z' ORDER BY time DESC LIMIT 4 OFFSET 2
name: data
| time | atan2 |
|---|---|
| 2018-06-24T23:58:00Z | 0.0166179004 |
| 2018-06-24T23:57:00Z | -2.3211306482 |
| 2018-06-24T23:56:00Z | 1.8506549463 |
| 2018-06-24T23:55:00Z | -0.0768444917 |
Advanced syntax
1. SELECT ATAN2(<function()>, <function()>) FROM_clause [WHERE_clause] GROUP_BY_clause [ORDER_BY_clause] [LIMIT_clause] [OFFSET_clause] [SLIMIT_clause] [SOFFSET_clause]
The advanced syntax requires a GROUP BY time() clause and a nested InfluxQL function. The query first calculates the results for the nested function at the specified GROUP BY time() interval and then applies the ATAN2() function to those results.
ATAN2() supports the following nested functions: COUNT(), MEAN(), MEDIAN(), MODE(), SUM(), FIRST(), LAST(), MIN(), MAX(), and PERCENTILE().
Examples
Calculate arctangents of mean values
Return the arctangents of mean as divided by average bs. Averages are calculated at 2-hour intervals.
1. SELECT ATAN2(MEAN("b"), MEAN("a")) FROM "data" WHERE time >= '2018-06-24T12:00:00Z' AND time <= '2018-06-25T00:00:00Z' GROUP BY time(2h)
name: data
| time | atan2 |
|---|---|
| 2018-06-24T12:00:00Z | -0.8233039154 |
| 2018-06-24T14:00:00Z | 1.6676707651 |
| 2018-06-24T16:00:00Z | 2.3853882606 |
| 2018-06-24T18:00:00Z | -1.0180694195 |
| 2018-06-24T20:00:00Z | -0.2601965301 |
| 2018-06-24T22:00:00Z | 2.1893237434 |
| 2018-06-25T00:00:00Z | -2.5572285037 |
CEIL()
Returns the subsequent value rounded up to the nearest integer.
Basic syntax
1. SELECT CEIL( [ * | <field_key> ] ) FROM_clause [WHERE_clause] [GROUP_BY_clause] [ORDER_BY_clause] [LIMIT_clause] [OFFSET_clause] [SLIMIT_clause] [SOFFSET_clause]
CEIL(field_key)
Returns the field values associated with the field key rounded up to the nearest integer.
CEIL(*)
Returns the field values associated with each field key in the measurement rounded up to the nearest integer.
CEIL() supports int64 and float64 field value data types.
Supports GROUP BY clauses that group by tags but not GROUP BY clauses that group by time. To use CEIL() with a GROUP BY time() clause, see Advanced syntax.
Examples
The examples below use the following subsample of the NOAA water sample data:
1. SELECT "water_level" FROM "h2o_feet" WHERE "location" = 'santa_monica' AND time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:30:00Z'
name: h2o_feet
| time | water_level |
|---|---|
| 2019-08-18T00:00:00Z | 2.3520000000 |
| 2019-08-18T00:06:00Z | 2.3790000000 |
| 2019-08-18T00:12:00Z | 2.3430000000 |
| 2019-08-18T00:18:00Z | 2.3290000000 |
| 2019-08-18T00:24:00Z | 2.2640000000 |
| 2019-08-18T00:30:00Z | 2.2670000000 |
Calculate the ceiling of field values associated with a field key
Return field values in the water_level field key in the h2o_feet measurement rounded up to the nearest integer.
1. SELECT CEIL("water_level") FROM "h2o_feet" WHERE "location" = 'santa_monica' AND time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:30:00Z'
name: h2o_feet
| time | ceil |
|---|---|
| 2019-08-17T00:00:00Z | 3.0000000000 |
| 2019-08-17T00:06:00Z | 3.0000000000 |
| 2019-08-17T00:12:00Z | 3.0000000000 |
| 2019-08-17T00:18:00Z | 3.0000000000 |
| 2019-08-17T00:24:00Z | 3.0000000000 |
| 2019-08-17T00:30:00Z | 3.0000000000 |
Calculate the ceiling of field values associated with each field key in a measurement
Return field values for each field key that stores numeric values in the h2o_feet measurement rounded up to the nearest integer. The h2o_feet measurement has one numeric field: water_level.
1. SELECT CEIL(*) FROM "h2o_feet" WHERE "location" = 'santa_monica' AND time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:30:00Z'
name: h2o_feet
| time | ceil_water_level |
|---|---|
| 2019-08-17T00:00:00Z | 3.0000000000 |
| 2019-08-17T00:06:00Z | 3.0000000000 |
| 2019-08-17T00:12:00Z | 3.0000000000 |
| 2019-08-17T00:18:00Z | 3.0000000000 |
| 2019-08-17T00:24:00Z | 3.0000000000 |
| 2019-08-17T00:30:00Z | 3.0000000000 |
Calculate the ceiling of field values associated with a field key and include several clauses
Return field values associated with the water_level field key rounded up to the nearest integer in the time range between 2019-08-18T00:00:00Z and 2019-08-18T00:30:00Z with results in descending timestamp order. The query also limits the number of points returned to four and offsets results by two points.
1. SELECT CEIL("water_level") FROM "h2o_feet" WHERE time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:30:00Z' AND "location" = 'santa_monica' ORDER BY time DESC LIMIT 4 OFFSET 2
name: h2o_feet
| time | ceil |
|---|---|
| 2019-08-17T00:18:00Z | 3.0000000000 |
| 2019-08-17T00:12:00Z | 3.0000000000 |
| 2019-08-17T00:06:00Z | 3.0000000000 |
| 2019-08-17T00:00:00Z | 3.0000000000 |
Advanced syntax
1. SELECT CEIL(<function>( [ * | <field_key> | /<regular_expression>/ ] )) FROM_clause [WHERE_clause] GROUP_BY_clause [ORDER_BY_clause] [LIMIT_clause] [OFFSET_clause] [SLIMIT_clause] [SOFFSET_clause]
The advanced syntax requires a GROUP BY time() clause and a nested InfluxQL function. The query first calculates the results for the nested function at the specified GROUP BY time() interval and then applies the CEIL() function to those results.
CEIL() supports the following nested functions: COUNT(), MEAN(), MEDIAN(), MODE(), SUM(), FIRST(), LAST(), MIN(), MAX(), and PERCENTILE().
Examples
Calculate mean values rounded up to the nearest integer
Return the mean water_levels that are calculated at 12-minute intervals and rounds them up to the nearest integer.
1. SELECT CEIL(MEAN("water_level")) FROM "h2o_feet" WHERE time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:30:00Z' AND "location" = 'santa_monica' GROUP BY time(12m)
name: h2o_feet
| time | ceil |
|---|---|
| 2019-08-17T00:00:00Z | 3.0000000000 |
| 2019-08-17T00:12:00Z | 3.0000000000 |
| 2019-08-17T00:24:00Z | 3.0000000000 |
COS()
Returns the cosine of the field value.
Basic syntax
1. SELECT COS( [ * | <field_key> ] ) FROM_clause [WHERE_clause] [GROUP_BY_clause] [ORDER_BY_clause] [LIMIT_clause] [OFFSET_clause] [SLIMIT_clause] [SOFFSET_clause]
COS(field_key)
Returns the cosine of field values associated with the field key.
COS(*)
Returns the cosine of field values associated with each field key in the measurement.
COS() supports int64 and float64 field value data types.
Supports GROUP BY clauses that group by tags but not GROUP BY clauses that group by time. To use COS() with a GROUP BY time() clause, see Advanced syntax.
Examples
The examples below use the following subsample of the NOAA water sample data:
1. SELECT "water_level" FROM "h2o_feet" WHERE time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:30:00Z' AND "location" = 'santa_monica'
name: h2o_feet
| time | water_level |
|---|---|
| 2019-08-18T00:00:00Z | 2.3520000000 |
| 2019-08-18T00:06:00Z | 2.3790000000 |
| 2019-08-18T00:12:00Z | 2.3430000000 |
| 2019-08-18T00:18:00Z | 2.3290000000 |
| 2019-08-18T00:24:00Z | 2.2640000000 |
| 2019-08-18T00:30:00Z | 2.2670000000 |
Calculate the cosine of field values associated with a field key
Return the cosine of field values in the water_level field key in the h2o_feet measurement.
1. SELECT COS("water_level") FROM "h2o_feet" WHERE time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:30:00Z' AND "location" = 'santa_monica'
name: h2o_feet
| time | cos |
|---|---|
| 2019-08-18T00:00:00Z | -0.7041346171 |
| 2019-08-18T00:06:00Z | -0.7230474420 |
| 2019-08-18T00:12:00Z | -0.6977155876 |
| 2019-08-18T00:18:00Z | -0.6876182920 |
| 2019-08-18T00:24:00Z | -0.6390047316 |
| 2019-08-18T00:30:00Z | -0.6413094611 |
Calculate the cosine of field values associated with each field key in a measurement
Return the cosine of field values for each numeric field in the h2o_feet measurement. The h2o_feet measurement has one numeric field: water_level.
1. SELECT COS(*) FROM "h2o_feet" WHERE time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:30:00Z' AND "location" = 'santa_monica'
name: h2o_feet
| time | cos_water_level |
|---|---|
| 2019-08-18T00:00:00Z | -0.7041346171 |
| 2019-08-18T00:06:00Z | -0.7230474420 |
| 2019-08-18T00:12:00Z | -0.6977155876 |
| 2019-08-18T00:18:00Z | -0.6876182920 |
| 2019-08-18T00:24:00Z | -0.6390047316 |
| 2019-08-18T00:30:00Z | -0.6413094611 |
Calculate the cosine of field values associated with a field key and include several clauses
Return the cosine of field values associated with the water_level field key in the time range between 2019-08-18T00:00:00Z and 2019-08-18T00:30:00Z with results in descending timestamp order. The query also limits the number of points returned to four and offsets results by two points.
1. SELECT COS("water_level") FROM "h2o_feet" WHERE time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:30:00Z' AND "location" = 'santa_monica' ORDER BY time DESC LIMIT 4 OFFSET 2
name: h2o_feet
| time | cos |
|---|---|
| 2019-08-18T00:18:00Z | -0.6876182920 |
| 2019-08-18T00:12:00Z | -0.6977155876 |
| 2019-08-18T00:06:00Z | -0.7230474420 |
| 2019-08-18T00:00:00Z | -0.7041346171 |
Advanced syntax
1. SELECT COS(<function>( [ * | <field_key> ] )) FROM_clause [WHERE_clause] GROUP_BY_clause [ORDER_BY_clause] [LIMIT_clause] [OFFSET_clause] [SLIMIT_clause] [SOFFSET_clause]
The advanced syntax requires a GROUP BY time() clause and a nested InfluxQL function. The query first calculates the results for the nested function at the specified GROUP BY time() interval and then applies the COS() function to those results.
COS() supports the following nested functions: COUNT(), MEAN(), MEDIAN(), MODE(), SUM(), FIRST(), LAST(), MIN(), MAX(), and PERCENTILE().
Examples
Calculate the cosine of mean values
Return the cosine of mean water_levels that are calculated at 12-minute intervals.
1. SELECT COS(MEAN("water_level")) FROM "h2o_feet" WHERE time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:30:00Z' AND "location" = 'santa_monica' GROUP BY time(12m)
name: h2o_feet
| time | cos |
|---|---|
| 2019-08-18T00:00:00Z | -0.7136560605 |
| 2019-08-18T00:12:00Z | -0.6926839105 |
| 2019-08-18T00:24:00Z | -0.6401578165 |
CUMULATIVE_SUM()
Returns the running total of subsequent field values.
Basic syntax
1. SELECT CUMULATIVE_SUM( [ * | <field_key> | /<regular_expression>/ ] ) FROM_clause [WHERE_clause] [GROUP_BY_clause] [ORDER_BY_clause] [LIMIT_clause] [OFFSET_clause] [SLIMIT_clause] [SOFFSET_clause]
CUMULATIVE_SUM(field_key)
Returns the running total of subsequent field values associated with the field key.
CUMULATIVE_SUM(/regular_expression/)
Returns the running total of subsequent field values associated with each field key that matches the regular expression.
CUMULATIVE_SUM(*)
Returns the running total of subsequent field values associated with each field key in the measurement.
CUMULATIVE_SUM() supports int64 and float64 field value data types.
Supports GROUP BY clauses that group by tags but not GROUP BY clauses that group by time. To use CUMULATIVE_SUM() with a GROUP BY time() clause, see Advanced syntax.
Examples
The examples below use the following subsample of the NOAA water sample data:
1. SELECT "water_level" FROM "h2o_feet" WHERE time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:30:00Z' AND "location" = 'santa_monica'
name: h2o_feet
| time | water_level |
|---|---|
| 2019-08-18T00:00:00Z | 2.3520000000 |
| 2019-08-18T00:06:00Z | 2.3790000000 |
| 2019-08-18T00:12:00Z | 2.3430000000 |
| 2019-08-18T00:18:00Z | 2.3290000000 |
| 2019-08-18T00:24:00Z | 2.2640000000 |
| 2019-08-18T00:30:00Z | 2.2670000000 |
Calculate the cumulative sum of the field values associated with a field key
Return the running total of the field values in the water_level field key and in the h2o_feet measurement.
1. SELECT CUMULATIVE_SUM("water_level") FROM "h2o_feet" WHERE time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:30:00Z' AND "location" = 'santa_monica'
name: h2o_feet
| time | cumulative_sum |
|---|---|
| 2019-08-18T00:00:00Z | 2.3520000000 |
| 2019-08-18T00:06:00Z | 4.7310000000 |
| 2019-08-18T00:12:00Z | 7.0740000000 |
| 2019-08-18T00:18:00Z | 9.4030000000 |
| 2019-08-18T00:24:00Z | 11.6670000000 |
| 2019-08-18T00:30:00Z | 13.9340000000 |
Calculate the cumulative sum of the field values associated with each field key in a measurement
Return the running total of the field values for each numeric field in the h2o_feet measurement. The h2o_feet measurement has one numeric field: water_level.
1. SELECT CUMULATIVE_SUM(*) FROM "h2o_feet" WHERE time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:30:00Z' AND "location" = 'santa_monica'
name: h2o_feet
| time |
(本文超出站点单文档体积上限,已截断)
