Is there LAG window function or equivalent in QuestDB?

I’m trying to query the diff between row values, in SQL it would be something like

SELECT timestamp, price - LAG(price) OVER (ORDER BY timestamp) as price_diff
from trades

But QuestDB returns Window function expected error at the position of LAG.

Is there a similar window function in QuestDB that can work instead of LAG?

You can use first_value window function like to simulate LAG function:

first_value(value) OVER (ORDER BY timestamp ROWS 1 PRECEDING) as prev_value

... same as

LAG(value) OVER (ORDER BY timestamp)