I have a data set that looks like this:
shop_id,item_id,time,value
150,1,2015-07-10,3
150,1,2015-07-11,5
150,1,2015-07-13,2
150,2,2015-07-10,15
150,2,2015-07
This is a Sql based solution
First you need a dates table
Date table query. Note this will create a physical table in your database.
;with cte as
(
select cast('2000-01-01' as datetime) as Dates -- Start date
union all
select dateadd(MM,1,Dates)
from cte
where Dates < '2099-12-01' -- End date
)
select *
INTO Date_table
from CTE
Then you need to left outer join your table with Date_table to get the missing dates.
SELECT A.shop_id,
A.item_id,
DT.dates,
Isnull(Y.value, 0)
FROM date_table DT
CROSS JOIN(SELECT DISTINCT shop_id,
item_id
FROM yourtable) A
LEFT OUTER JOIN yourtable Y
ON t.[time] = DT.dates
AND A.shop_id = Y.shop_id
AND A.item_id = Y.item_id