I am VERY new to stored procedures, so I'll admit I'm being a little lazy here (I just bought an Amazon book on Sprocs that I'm still expecting). But I also want to gain wisdom around programming philosophy (I'm very comfy with VBA). What I want to do is write a Sproc that does what I outline below ... Anyone have 5 mins to spare to outline the programming?
Table A looks like this
Person Year Company
John 2001 <Null>
John 2000 <Null>
John 1999 ABC
John 1998 <Null>
John 1997 XYZ
What I want to do is loop through the table, starting with the lowest year (1997 in this example). In 1997, we know John was with Company XYZ. Then move to 1998, which is blank. Since XYZ was his most recent company, I want to fill in XYZ in 1998. Then move to 1999, where we know he was with ABC. In 2000, we will fill in ABC since we assume he was the same company. And so on.
Thoughts? Sorry to ask so much.
Table A looks like this
Person Year Company
John 2001 <Null>
John 2000 <Null>
John 1999 ABC
John 1998 <Null>
John 1997 XYZ
What I want to do is loop through the table, starting with the lowest year (1997 in this example). In 1997, we know John was with Company XYZ. Then move to 1998, which is blank. Since XYZ was his most recent company, I want to fill in XYZ in 1998. Then move to 1999, where we know he was with ABC. In 2000, we will fill in ABC since we assume he was the same company. And so on.
Thoughts? Sorry to ask so much.