I have what I thought was a simple problem, but maybe I underestimated it (or BigQuery's lack of recursive CTEs):
Let's say that I have this table:
SELECT DATE("2021-09-01") AS date, 50 AS a, 0.5 AS b, 2 AS c
UNION ALL
SELECT DATE("2021-09-02") AS date, NULL AS a, 0.6 AS b, 1 AS c
UNION ALL
SELECT DATE("2021-09-03") AS date, NULL AS a, 0.4 AS b, 3 AS c
And so forth until the end of 2021. That is:
Column a only has a value in the first row, while the others vary until the end of the table.
And I wish to generate another column ('calculation'), with the following operation until the end of the table:
row 1 = a * (1 - b) + c
row 2 = row 1 * (1 - b) + c
row 3 = row 2 * (1 - b) + c
etc.
Thus giving a result like this:
date a b c calculation
2021-09-01 50 0.5 2 27
2021-09-02 0.6 1 11.8
2021-09-03 0.4 3 10.08
The key being: I need to get the result from the previous row and then apply the same operation to it and so forth.
What would be a good way to do this?
(Note: C might be larger than 709.7827, which rules out using EXP(C) Mikhail's answer below – though it's a promising start!)
Thanks!

