Started with TSQL last Wednesday...
I have the following data in tblStage1:
PROJECT USERNAME DATE PERCENTAGE
--------- ----------------- ------------ ----------------------
Project 1 DOMAIN\Chris.User 03/01/2013 0.25
Project 1 DOMAIN\Chris.User 05/01/2013 0.75
Project 1 DOMAIN\Chris.User 07/01/2013 1
Project 1 DOMAIN\John.User 02/01/2013 1
Project 1 DOMAIN\John.User 06/01/2013 0.5
I have the following data in tblRawData
PROJECT START_DATE END_DATE
---------- ----------- ----------
Project 1 01/01/2013 09/01/2013
I would like to get the following data out into tblStage2 (data points are bound by START_DATE and END_DATE):
PROJECT USERNAME DATE PERCENTAGE
--------- ----------------- ------------ ----------------------
Project 1 DOMAIN\Chris.User 01/01/2013 0
Project 1 DOMAIN\Chris.User 02/01/2013 0
Project 1 DOMAIN\Chris.User 03/01/2013 0.25
Project 1 DOMAIN\Chris.User 04/01/2013 0.25
Project 1 DOMAIN\Chris.User 05/01/2013 0.75
Project 1 DOMAIN\Chris.User 06/01/2013 0.75
Project 1 DOMAIN\Chris.User 07/01/2013 1
Project 1 DOMAIN\Chris.User 08/01/2013 1
Project 1 DOMAIN\Chris.User 09/01/2013 1
Project 1 DOMAIN\John.User 01/01/2013 0
Project 1 DOMAIN\John.User 02/01/2013 1
Project 1 DOMAIN\John.User 03/01/2013 1
Project 1 DOMAIN\John.User 04/01/2013 1
Project 1 DOMAIN\John.User 05/01/2013 1
Project 1 DOMAIN\John.User 06/01/2013 0.5
Project 1 DOMAIN\John.User 07/01/2013 0.5
Project 1 DOMAIN\John.User 08/01/2013 0.5
Project 1 DOMAIN\John.User 09/01/2013 0.5
I realize that there are a number of topics that relate to this subject such as this. I my case, I don't have any particular restrictions and I am looking for a clean routine that is relatively easy to understand.
I know there is a DateAdd
function, but I haven't seen any INSERT INTO
commands in the example statements. I am confused as to how one would iterate through the data set and create the interpolated values. I am still too green to understand the full context of the other examples and would greatly appreciate any help or clarification.
Edit Added additional information to the sample data for a better indication of my final goal. I will have multiple users in this data set. The USERNAME column is placed into the data set by the original source (a people picker on an InfoPath form). All "Percentages" are "0" until the first value is assigned then they retain that value until it is changed or the project reaches its end date. I hope this helps clarify!