Query data with SQL
InfluxDB Clustered is currently only available to a limited group of InfluxData customers.
If interested in being part of the limited access group, please
contact the InfluxData Sales team.
Learn to query data stored in InfluxDB using SQL.
When working with InfluxDB’s implementation of SQL, a measurement is structured as a table, and time, fields, and tags are structured as columns.
List columns in a measurement
SHOW COLUMNS IN measurement
A basic SQL query that queries data from InfluxDB most commonly includes
SELECT temp, room FROM home WHERE time >= now() - INTERVAL '1 day'
Use aggregate and selector functions to perform aggregate operations on your time series data.
Aggregate fields by groups
mean(field1) AS mean,
selector_first(field2)['value'] as first,
GROUP BY tag
Aggregate by time-based intervals
DATE_BIN(INTERVAL '1 hour', time, '2022-01-01T00:00:00Z'::TIMESTAMP) AS time,
GROUP BY 1, tag1
CAST function or double-colon
:: casting shorthand syntax to cast a value to a specific type.
-- CAST clause
SELECT CAST(1234.5 AS BIGINT)
-- Double-colon casting shorthand
locf to fill gaps of time where no data is returned.
date_bin_gapfill(INTERVAL '30 minutes', time) as _time,
time >= '2022-01-01T08:00:00Z'
AND time <= '2022-01-01T10:00:00Z'
GROUP BY _time, room
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.