I have a table with time column in it. I am trying to create a stored procedure (SQL Server 2008) to get a string for each row with all previous years last value and current row value. For example, if I have the following table.
_________________ time value _________________ mar-2009 1 _________________ may-2009 2 _________________ jan-2010 3 _________________ apr-2011 4 _________________ feb-2011 5 _________________ jan-2012 6 _________________
I am trying to get the following result
____________________________________________________ time value Result ____________________________________________________ mar-2009 1 "2009,1" ____________________________________________________ may-2009 2 "2009,2" ____________________________________________________ jan-2010 3 "2009,2,2010,3" ____________________________________________________ apr-2011 4 "2009,2,2010,3,2011,4" ____________________________________________________ feb-2011 5 "2009,2,2010,3,2011,5" ____________________________________________________ jan-2012 6 "2009,2,2010,3,2011,5,2012,6" ____________________________________________________