Documentation

SELECT statement

Use the SELECT statement to query data from an InfluxDB measurement. The SELECT clause is required when querying data in SQL.

Syntax

SELECT a, b, "time" FROM <measurement>
  • Copy
  • Fill window

The SELECT clause supports the following:

  • SELECT * - return all tags, fields and timestamps.
  • SELECT DISTINCT to return all distinct (different) values.
  • SELECT <"field" or "tag"> - returns a specified field or tag.
  • SELECT <"field" or "tag">, <"field" or "tag"> - returns more than one tag or field.
  • SELECT <"field"> AS a - return the field as the alias.

Examples

The following examples use data from the NOAA database. To download the NOAA test data see NOAA water sample data.

Select all fields and tags from a measurement

SELECT * FROM h2o_feet LIMIT 10
  • Copy
  • Fill window

View example results

Select specific tags and fields from a measurement

SELECT "location", "water_level" FROM "h2o_feet"
  • Copy
  • Fill window

View example results

Select a field, tag and timestamp from a measurement

SELECT "water_level", "location", "time" FROM "h2o_feet"
  • Copy
  • Fill window

View example results

Select a field and perform basic arithmetic

The following query takes the value of water_level, multiplies it by 3 and adds 5 to the result.

SELECT ("water_level" * 3) + 5 FROM "h2o_feet"
  • Copy
  • Fill window

View example results


Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Read more

InfluxDB 3 Core and Enterprise are now in Beta

InfluxDB 3 Core and Enterprise are now available for beta testing, available under MIT or Apache 2 license.

InfluxDB 3 Core is a high-speed, recent-data engine that collects and processes data in real-time, while persisting it to local disk or object storage. InfluxDB 3 Enterprise is a commercial product that builds on Core’s foundation, adding high availability, read replicas, enhanced security, and data compaction for faster queries. A free tier of InfluxDB 3 Enterprise will also be available for at-home, non-commercial use for hobbyists to get the full historical time series database set of capabilities.

For more information, check out:

InfluxDB Cloud Serverless