QuestDB attempts to implement standard ANSI SQL. We also attempt to be PostgresSQL compatible, although some of it is work in progress. This page presents the main extensions we bring to SQL and the main differences that one might find in SQL but not in QuestDB's dialect
We have extended SQL language to support our data storage model and simplify semantics of time series queries.
LATEST BY is a clause introduced to help perform UPDATE and DELETE operations within an append-only framework.
select avg(balance) from accounts sample by 1M
Important differences from standard SQL
SELECT * FROM Optionality
select * from is optional.
SELECT * FROM tab; achieves the same effect as
select * from makes SQL look more complete on a single time, there are examples where its optionality makes things a lot easier to read. See examples in GROUP BY section.
We do not support explicit
GROUP BY clause. Instead, QuestDB optimiser derives group-by implementation from
In standard SQL, users might write a query like the below.
SELECT a, b, c, d, sum(e) FROM tab GROUP BY a, b, c, d;
However, enumerating subset of
SELECT columns in the
GROUP BY clause redundant and therefore unnecessary.
The same SQL in QuestDB SQL-dialect will look like:
SELECT a, b, c, d, sum(e) FROM tab;
Let's look at another more complex example using HAVING in standard SQL.
SELECT a, b, c, d, sum(e) FROM tab GROUP BY a, b, c, d HAVING sum(e) > 100;
In QuestDB's dialect,
select * from optionality and featherweight sub-queries come to the rescue to create a
smaller, more readable query, without unnecessary repetitive aggregations.
(SELECT a, b, c, d, sum(e) s FROM tab) WHERE s > 100;