Documentation

Perform a basic SQL query

InfluxDB 3 Core is in Public Beta

InfluxDB 3 Core is in public beta and available for testing and feedback, but is not meant for production use yet. Both the product and this documentation are works in progress. We welcome and encourage your input about your experience with the beta and invite you to join our public channels for updates and to share feedback.

Beta expectations and recommendations

The InfluxDB SQL implementation is powered by the Apache Arrow DataFusion query engine which provides an SQL syntax similar to other relational query languages.

A basic SQL query that queries data from InfluxDB 3 Core most commonly includes the following clauses:

* Required
  • * SELECT: Specify fields, tags, and calculations to output from a table or use the wildcard alias (*) to select all fields and tags from a table.
  • * FROM: Specify the table to query data from.
  • WHERE: Only return rows that meets the specified conditions–for example, the time is within a time range, a tag has a specific value, or a field value is above or below a specified threshold.
SELECT
  temp,
  hum,
  room
FROM home
WHERE
  time >= '2025-03-28T08:00:00Z'
  AND time <= '2025-03-28T20:00:00Z'
  • Copy
  • Fill window

Result set

If at least one row satisfies the query, InfluxDB 3 Core returns row data in the query result set. An SQL query result set includes columns listed in the query’s SELECT statement.

Basic query examples

Sample data

The following examples use the Home sensor sample data. To run the example queries and return results, write the sample data to your InfluxDB 3 Core database before running the example queries.

Query data within time boundaries

  • Use the SELECT clause to specify what tags and fields to return. To return all tags and fields, use the wildcard alias (*).
  • Specify the table to query in the FROM clause.
  • Specify time boundaries in the WHERE clause. Include time-based predicates that compare the value of the time column to a timestamp. Use the AND logical operator to chain multiple predicates together.
SELECT *
FROM home
WHERE
  time >= '2025-03-28T08:00:00Z'
  AND time <= '2025-03-28T12:00:00Z'
  • Copy
  • Fill window

Query time boundaries can be relative or absolute.

Query with relative time boundaries

Query with absolute time boundaries

Query data using a time zone offset

Query data without time boundaries

To query data without time boundaries, do not include any time-based predicates in your WHERE clause.

Querying data without time bounds can return an unexpected amount of data. The query may take a long time to complete and results may be truncated.

SELECT * FROM home
  • Copy
  • Fill window

Query specific fields and tags

To query specific fields, include them in the SELECT clause. If querying multiple fields or tags, comma-delimit each. If a field or tag key includes special characters or spaces or is case-sensitive, wrap the key in double-quotes.

SELECT time, room, temp, hum FROM home
  • Copy
  • Fill window

Query fields based on tag values

  • Include the fields you want to query and the tags you want to base conditions on in the SELECT clause.
  • Include predicates in the WHERE clause that compare the tag identifier to a string literal. Use logical operators to chain multiple predicates together and apply multiple conditions.
SELECT * FROM home WHERE room = 'Kitchen'
  • Copy
  • Fill window

Query points based on field values

  • In the SELECT clause, include fields you want to query.
  • In the WHERE clause, include predicates that compare the field identifier to a value or expression. Use logical operators (AND, OR) to chain multiple predicates together and apply multiple conditions.
SELECT co, time FROM home WHERE co >= 10 OR co <= -10
  • Copy
  • Fill window

Alias queried fields and tags

To alias or rename fields and tags that you query, pass a string literal after the field or tag identifier in the SELECT clause. You can use the AS clause to define the alias, but it isn’t necessary. The following queries are functionally the same:

SELECT temp 'temperature', hum 'humidity' FROM home

SELECT temp AS 'temperature', hum AS 'humidity' FROM home
  • Copy
  • Fill window

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: