If the rows are coming from a database, the last (or next) known value can be obtained by the SELECT statement:
This way it doesn't matter, if the values for consecutive dates are missing.
( SELECT amount FROM sales WHERE product = s.product AND amount IS NOT NULL AND date > s.date ORDER BY date LIMIT 1) AS next_amount,
( SELECT amount FROM sales WHERE product = s.product AND amount IS NOT NULL AND date < s.date ORDER BY date DESC LIMIT 1) AS prev_amount
FROM sales s
And you still call it a fact?
Originally Posted by Bergtroll