We have a table with several records where we need to perform the moving average of the last 90 days considering only grouping by one column (fluxo_id_card).

If we don't consider the rolling avarage, the calculation is performed as follows:

But what happens is that we need to display these results in a month-to-month progression, where each month we view the average of the last 90 days.
For the Rolling average, the basic syntax is:

But we don’t have a certain number of lines that each card would occupy, and that Rows Between does not currently support the COUNT function.
How can we adapt this calculation to the new context without changing the original table in the model?
Best answer by Augusto Silva
View original