Query data with SQL
InfluxDB 3 Enterprise is in Public Alpha
InfluxDB 3 Enterprise is in public alpha and available for testing and feedback, but is not meant for production use. Both the product and this documentation are works in progress. We welcome and encourage your input about your experience with the alpha and invite you to join our public channels for updates and to share feedback.
Learn to query data stored in InfluxDB 3 Enterprise using SQL.
- Explore your schema with SQL
- Perform a basic SQL query
- Aggregate data with SQL
- Cast values to different types
- Fill gaps in data
Explore your schema with SQL
Use SQL to explore your data schema in your InfluxDB 3 Enterprise database.
List tables
SHOW TABLES
List columns in a table
SHOW COLUMNS IN table
Perform a basic SQL query
A basic SQL query that queries data from InfluxDB 3 Enterprise most commonly includes SELECT
, FROM
, and WHERE
clauses.
SELECT temp, room FROM home WHERE time >= now() - INTERVAL '1 day'
Aggregate data with SQL
Use aggregate and selector functions to perform aggregate operations on your time series data.
Aggregate fields by groups
SELECT
mean(field1) AS mean,
selector_first(field2)['value'] as first,
tag1
FROM home
GROUP BY tag
Aggregate by time-based intervals
SELECT
DATE_BIN(INTERVAL '1 hour', time, '2022-01-01T00:00:00Z'::TIMESTAMP) AS time,
mean(field1),
sum(field2),
tag1
FROM home
GROUP BY 1, tag1
Cast values to different types
Use the 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
SELECT 1234.5::BIGINT
Fill gaps in data
Use date_bin_gapfill
with interpolate
or locf
to fill gaps of time where no data is returned.
SELECT
date_bin_gapfill(INTERVAL '30 minutes', time) as time,
room,
interpolate(avg(temp))
FROM home
WHERE
time >= '2022-01-01T08:00:00Z'
AND time <= '2022-01-01T10:00:00Z'
GROUP BY 1, 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 3 Enterprise and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.