My question is this,
I have a query I’m working on and I have some values that are 0. I want to be able to take a value from a previous month that is not zero and put it in place of the zero. See the example below.
SELECT item,
stock,
sold,
level,
month,
year
FROM agingdata
GROUP BY item,
stock,
sold,
month,
year,
level
HAVING ( item = @Item )
ORDER BY year,
month

So I want take the number 2455 and input it into the stock where it says 0, taking last months balance number as the current months stock level. Is that even possible?
You can find the previous non-zero level per item (for zero level items) using this query:
This will work even if the previous non-zero level is several months before.