Reputation: 1
I have a table which will vary in size(i.e. number of columns) but the last column contains a piece of information which I want to be "copied up" to all rows above.
I want to create a query which turns the below table...
ID Cust_Number
1 aaa
2 aaa
3 aaa
4 aaa
5 aaa
6 aaa
7 aaa
8 aaa
9 aaa
10 bbb
to turn into this:
ID Cust_Number
1 bbb
2 bbb
3 bbb
4 bbb
5 bbb
6 bbb
7 bbb
8 bbb
9 bbb
10 bbb
Upvotes: 0
Views: 35
Reputation: 40481
Maybe something like this:
UPDATE YourTable t
SET T.CustNumber = (SELECT TOP 1 s.Cust_Number FROM YourTable s
ORDER BY s.ID DESC)
Upvotes: 2