Reputation: 123
I currently store data in QuestDB. I need to return the result of subtraction between subsequent field values. Does QuestDB have such a function out of the box in the SQL query syntax? This is what InfluxDB has got: https://docs.influxdata.com/influxdb/v1.8/query_language/functions/#difference
Upvotes: 2
Views: 682
Reputation: 141
We have released QuestDB 8.2.2 which includes LAG
and LEAD
support.
Upvotes: 0
Reputation: 4032
There has been support for Window functions for a few months already, and even if LAG
is still not there, you can actually get this using the FIRST_VALUE
window function.
If you want to try it out, you can run the following query at the questdb demo site
SELECT
timestamp, symbol,
price,
first_value(price) OVER (
PARTITION BY symbol
ROWS BETWEEN 1 PRECEDING AND CURRENT ROW
)
FROM
trades
where timestamp in '2024' and symbol = 'BTC-USD'
Upvotes: 1
Reputation: 1315
This is not yet supported, but there is a ticket to track addition of LAG/LEAD functions here: https://github.com/questdb/questdb/issues/1268
Upvotes: 0