SQL execution order
QuestDB attempts to implement standard ANSI SQL. We also try to be compatible with PostgreSQL, although parts of this are a work in progress. QuestDB implements these clauses which have the following execution order:
- FROM
- ON
- JOIN
- WHERE
- LATEST ON
- GROUP BY (optional)
- WITH
- HAVING (implicit)
- SELECT
- DISTINCT
- ORDER BY
- LIMIT
We have also implemented sub-queries that users may execute at any part of a query that mentions a table name. The sub-query implementation adds almost zero execution cost to SQL. We encourage the use of sub-queries as they add flavors of functional language features to traditional SQL.
For more information on the SQL extensions in QuestDB which deviate from ANSI SQL and PostgreSQL, see the SQL extensions documentation.