Get the last row that was left outside of a timeframed SQL query
The simplest (I think so) solution is

  ( SELECT * 
    FROM A
    WHERE `timestamp` BETWEEN @from AND @till )
UNION ALL
  ( SELECT * 
    FROM A
    WHERE `timestamp` &lt; @from
    ORDER BY `timestamp` DESC LIMIT 1 )
ORDER BY `timestamp` ASC


Alternative:

WITH cte AS ( SELECT `timestamp`, `value`, 
                     LEAD (`timestamp`) OVER (ORDER BY `timestamp`) `next`
              FROM A )
SELECT `timestamp`, `value`
FROM cte
WHERE (`timestamp` BETWEEN @from AND @till)
   OR (`next` BETWEEN @from AND @till)
ORDER BY `timestamp` ASC


One more:

WITH cte AS ( SELECT `timestamp`, `value`, 
                     CASE WHEN `timestamp` &gt;= @from THEN 1
                          ELSE ROW_NUMBER() OVER (ORDER BY `timestamp DESC`)
                     END grp
              FROM A
              WHERE `timestamp` &lt;= @till )
SELECT `timestamp`, `value`
FROM cte
WHERE grp = 1
ORDER BY `timestamp` ASC


One more else:

WITH cte AS ( SELECT `timestamp`, `value`, 
                     COALESCE(LEAD(`timestamp`) OVER (ORDER BY `timestamp DESC`),
                              `timestamp`) grp
              FROM A
              WHERE `timestamp` &lt;= @till )
SELECT `timestamp`, `value`
FROM cte
WHERE grp &gt;= @from
ORDER BY `timestamp` ASC