I've got the next situation (SQL SERVER 2012):
This is my source table (dates are dd-mm-yyyy):
id|startDate |updateDate |percentage
--|------------|------------|----------
01| 01-01-2015| 03-01-2015| 45
01| 01-01-2015| 05-01-2015| 80
01| 01-01-2015| 06-01-2015| 100
I want to end up with the folowing table :
id|date |percentage
--|------------|----------
01| 01-01-2015| 0
01| 02-01-2015| 0
01| 03-01-2015| 45
01| 04-01-2015| 45
01| 05-01-2015| 80
01| 06-01-2015| 100
My plan is to do a join with a date table, but my main concern is how to generate the records where the percentage is 0, since the source only has a startdate and a first updatedate.
So as I see it, first I need to do a datediff between startDate and first updateDate, en from there a datediff between current updateDate and the previous updateDate. Thats the bit where my concern is, how can I make this work?
thanks in advance!
PS. datetable is just a simple table with every date
id|date |month |etc...
--|------------|------|-------
01| 01-01-2015| 1 |
01| 02-01-2015| 1 |
01| 03-01-2015| 1 |
01| 04-01-2015| 1 |
01| 05-01-2015| 1 |
01| 06-01-2015| 1 |
etc...