Overview
January 3, 2025About 2 min
Overview
1 Syntax Overview
SELECT ⟨select_list⟩
FROM ⟨tables⟩
[WHERE ⟨condition⟩]
[GROUP BY ⟨groups⟩]
[HAVING ⟨group_filter⟩]
[FILL ⟨fill_methods⟩]
[ORDER BY ⟨order_expression⟩]
[OFFSET ⟨n⟩]
[LIMIT ⟨n⟩];
IoTDB query syntax provides the following clauses:
- SELECT Clause: The columns to include in the query results. For detailed syntax, see: SELECTClauses
- FROM Clause: Specifies the data source of the query, which can be a single table, multiple tables joined using the JOIN clause, or a subquery. For detailed syntax, see: FROM & JOIN Clauses
- WHERE Clause: Used to filter data, selecting only rows that meet specific conditions. This clause is logically executed immediately after the FROM clause. For detailed syntax, see:WHERE Clauses
- GROUP BY Clause: Used when data aggregation is needed, specifying the columns used for grouping. For detailed syntax, see: GROUP BY Clauses
- HAVING Clause: Used after the GROUP BY clause to filter data that has already been grouped. Similar to the WHERE clause, but the HAVING clause is executed after grouping. For detailed syntax, see: HAVING Clauses
- FILL Clause: Used to handle null values in the query results. Users can specify filling modes (such as the previous non-null value or linear interpolation) to fill null values with the FILL clause, facilitating data visualization and analysis. For detailed syntax, see: FILL Clauses
- ORDER BY Clause: Sorts the query results, specifying ascending (ASC) or descending (DESC) order, as well as handling of NULL values (NULLS FIRST or NULLS LAST). For detailed syntax, see: ORDER BY Clauses
- OFFSET Clause: Used to specify the starting position of the query results, that is, skipping the first OFFSET rows. Used in conjunction with the LIMIT clause. For detailed syntax, see: LIMIT and OFFSET Clauses
- LIMIT Clause: Limits the number of rows in the query results, often used with the OFFSET clause to implement pagination. For detailed syntax, see: LIMIT and OFFSET Clauses
2 Clause Execution Order
- FROM (table name)
- WHERE (condition filtering)
- SELECT (column names/expressions)
- GROUP BY (grouping)
- HAVING (condition filtering after grouping)
- FILL(null value filling)
- ORDER BY (sorting)
- OFFSET (offset amount)
- LIMIT (limit amount)