Given the following table:
CREATE TABLE balance (
confirmed_at TIMESTAMP WITH TIME ZONE NOT NULL,
value BIGINT
);
I want to select all rows where confirmed_at
is between start
and end
, however, I would also like the row that exists right before the time range. That way if there are no rows between the range, I still know the last value that was entered.
Is there a way to do this in a single query?