InfluxQL is an SQL-like query language that you can use to interact with data in TSDB for InfluxDB®. This topic describes the SELECT statement of InfluxQL and useful query syntax for exploring your data.
Basics | Configuration for obtaining query results | Suggestion for using query syntax |
---|---|---|
SELECT statement | ORDER BY time DESC | Time syntax |
WHERE clause | LIMIT and SLIMIT clauses | Regular expressions |
GROUP BY clause | OFFSET and SOFFSET clauses | Data types and cast operations |
INTO clause | Time zone clause | Merge operations |
Multiple statements | ||
Subqueries |
Sample data
This topic uses the sample data that is published by the Center for Operational Oceanographic Products and Services (CO-OPS) of National Oceanic and Atmospheric Administration (NOAA). For more information about how to download the data, see the “Sample data” section. The following example shows how to query the data.
Log on to the Influx command-line interface (CLI):
$ influx -ssl -username <Username> -password <Password> -host <Domain name> -port 3242 -precision rfc3339 -database NOAA_water_database
Connected to https://<Domain name>:3242 version 1.7.x
InfluxDB shell 1.7.x
>
Familiarize yourself with the following sample data in the h2o_feet
measurement:
name: h2o_feet
time | level description | location | water_level |
---|---|---|---|
2015-08-18T00:00:00Z | between 6 and 9 feet | coyote_creek | 8.12 |
2015-08-18T00:00:00Z | below 3 feet | santa_monica | 2.064 |
2015-08-18T00:06:00Z | between 6 and 9 feet | coyote_creek | 8.005 |
2015-08-18T00:06:00Z | below 3 feet | santa_monica | 2.116 |
2015-08-18T00:12:00Z | between 6 and 9 feet | coyote_creek | 7.887 |
2015-08-18T00:12:00Z | below 3 feet | santa_monica | 2.028 |
The data in the h2o_feet
measurement occurs at 6-minute intervals. The h2o_feet
measurement has one tag key named location
. The tag key has two tag values: coyote_creek
and santa_monica
. The h2o_feet
measurement also has two fields: level description
that stores the field values of the STRING type and water_level
that stores the field values of the FLOAT type. All of the data is stored in the NOAA_water_database
database.
Disclaimer: The original NOAA data does not contain the
level description
field. This field is added to obtain the field values of the STRING type.
InfluxDB® is a trademark registered by InfluxData, which is not affiliated with, and does not endorse, TSDB for InfluxDB®.