Perform a basic SQL query
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 most commonly includes the following clauses:
* Required- * 
SELECT: Specify fields, tags, and calculations to output from a measurement or use the wildcard alias (*) to select all fields and tags from a measurement. - * 
FROM: Specify the measurement to query data from. WHERE: Only return data that meets the specified conditions–for example, falls within a time range, contains specific tag values, or contains a field value outside a specified range.
Result set
If at least one row satisfies the query, InfluxDB Cloud Dedicated 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
- Query data within time boundaries
 - Query data without time boundaries
 - Query specific fields and tags
 - Query fields based on tag values
 - Query points based on field values
 - Alias queried fields and tags
 
Sample data
The following examples use the sample data written in the Get started writing data guide. To run the example queries and return results, write the sample data to your InfluxDB Cloud Dedicated database before running the example queries.
Query data within time boundaries
- Use the 
SELECTclause to specify what tags and fields to return. To return all tags and fields, use the wildcard alias (*). - Specify the measurement to query in the 
FROMclause. - Specify time boundaries in the 
WHEREclause. Include time-based predicates that compare the value of thetimecolumn to a timestamp. Use theANDlogical operator to chain multiple predicates together. 
Query time boundaries can be relative or absolute.
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 homeQuery 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 homeQuery fields based on tag values
- Include the fields you want to query and the tags you want to base conditions
on in the 
SELECTclause. - Include predicates in the 
WHEREclause 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'Query points based on field values
- In the 
SELECTclause, include fields you want to query. - In the 
WHEREclause, 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 <= -10Alias 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 homeWas 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 Cloud Dedicated and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.