'Copy value to another row based on similar ID

I am looking for a way to achieve the following in SQL:

Say I have a table:

UniqeID AccountNo Value
abc123 001ID stack500
efg567 001ID null

What I am trying to achieve is if AccountNo are same, I would like to fill that null with the value above it. Basically, for my purposes, if AccountNo. then value must be same. I tried the approach described here



Solution 1:[1]

Try the following:

UPDATE ttable --(or t1)
SET t1.Value = t2.Value 
FROM 
    ttable as t1
JOIN ttable as t2 ON t1.AccountNo = t2.AccountNo
WHERE t1.value IS NULL
AND t2.value IS NOT NULL

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ahmet hamza emra