SELECT statement to query data from an InfluxDB measurement.
SELECT clause is required when querying data in SQL.
SELECT a, b, "time" FROM <measurement>
Note: When querying InfluxDB, the
SELECT statement always requires a
The SELECT clause supports the following:
SELECT *- return all tags, fields and timestamps.
SELECT DISTINCTto 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.
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
Select specific tags and fields from a measurement
SELECT "location", "water_level" FROM "h2o_feet"
Select a field, tag and timestamp from a measurement
SELECT "water_level", "location", "time" FROM "h2o_feet"
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"
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.