I am stumped by what seems like a simple problem. We have the following Table.
ID--- ---Income--- ---Years Offset--- ---Income By Offset--- 1 1000 1 NULL 2 500 1 NULL 3 400 1 NULL 4 0 1 NULL 5 2000 2 NULL 6 0 2 NULL 7 400 2 NULL
What I would love to figure out how to do is to sum all of the income column by the "Years Offset column" and place in the first row of the "Income by Offset column." What would be awesome is if the Income by Offset column has values of 1900 in row 1 and 2400 in row 5 with the rest of them rows being untouched.
I know that this sound like a simple problem. But I have tried Window functions, Row_number(), SELF joining tables and a piece of it is solved with each but am having trouble putting it all together.
Thanks in advance, George
My Version of Your Table
Actual Query
Results