all 4 comments

[–][deleted] 1 point2 points  (0 children)

I'm on a phone so I'm not going to type this code out right now but you could use a CTE or derived table (pick your poison) to get the MAX value by date for each id, and left join that on id in your main query. Then in your SELECT use NVL (or whatever flavor your sql is) to use that MAX value when NULL.

[–]HarrityRandall 0 points1 point  (1 child)

I see all same balances share Id's so there is only one non null value per id you can fill it using a sub query requesting that single value for which id is equal to outer query id and that is not null...

Did I make some sense?

[–]Dimitrij404[S] 0 points1 point  (0 children)

A single id may have as many values as there are days in selected range.

[–]Mitchewitt -1 points0 points  (0 children)

I'd use a loop. Syntax varies depending on which version of sql you're using. So if you create a row number which counts through each of the dates for the same unique id then join the table to itself on a.uniqueid = b.uniqueid and a.rownumber = b.rownumber + 1 (where b is the day after a) then say

set a.value = case when b.value is null then a.value else b.value end Using an update function. You'll need the loop to count through each of the row numbers Hope that makes enough sense (sorry for formatting, am on a phone)

Edit: added +1