Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Common InfluxDB functions for InfluxDB Learning (2) selecting Class functions

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1) BOTTOM() function

Function: Returns the smallest N values in a field. The field type must be a long integer or float64 type.

Grammar:

SELECT BOTTOM([,],)[,] FROM [WHERE ] [GROUP BY ]

uses examples

> SELECT BOTTOM(water_level,3) FROM h3o_feetname: h3o_feet--------------time bottom2015-08-29T14:30:00Z -0.612015-08-29T14:36:00Z -0.5912015-08-30T15:18:00Z -0.594

This example returns the three smallest values in the water_level field of the table.

You can also query the associated tags together, but if the tag value is less than the value of N, the number of values returned will only take the one with the least field value in the tag.

As follows:

> SELECT BOTTOM(water_level,location,3) FROM h3o_feetname: h3o_feet--------------time bottom location2015-08-29T10:36:00Z -0.243 santa_monica2015-08-29T14:30:00Z -0.61 coyote_creek

The statement takes the minimum of three values, but only returns two values because the tag location has only two values.

2) FIRST() function

Function: Returns the oldest value in a field.

Grammar:

SELECT FIRST()[,] FROM [WHERE ] [GROUP BY ]

Examples:

> SELECT FIRST(water_level) FROM h3o_feet WHERE location = 'santa_monica'name: h3o_feet--------------time first2015-08-18T00:00:00Z 2.064

This statement returns the value and time of the oldest water_level field if location is santa_monica.

3) LAST() function

Function: Returns the most recent value in a field.

Grammar:

SELECT LAST()[,] FROM [WHERE ] [GROUP BY ]

Examples:

> SELECT LAST(water_level),location FROM h3o_feet WHERE time >= '2015-08-18T00:42:00Z' and time SELECT MAX(water_level),location FROM h3o_feetname: h3o_feet--------------time max location2015-08-29T07:24:00Z 9.964 coyote_creek

5) MIN() function

Function: Returns the minimum value in a field. The field type must be long, float64, or boolean.

Grammar:

SELECT MIN()[,] FROM [WHERE ] [GROUP BY ]

Examples:

> SELECT MIN(water_level),location FROM h3o_feetname: h3o_feet--------------time min location2015-08-29T14:30:00Z -0.61 coyote_creek

6) PERCENTILE() function

Function: Returns the percentile value ranked N. The type of field must be long or float64.

Percent values are integer or floating point numbers between 100 and 0, including 100.

Grammar:

SELECT PERCENTILE(, )[,] FROM [WHERE ] [GROUP BY ]

Examples:

> SELECT PERCENTILE(water_level,5),location FROM h3o_feetname: h3o_feet--------------time percentile location2015-08-28T12:06:00Z 1.122 santa_monica

That is, calculate the percentage of the water_level field according to different locations, and then take the fifth data.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report