我从我的函数中获取数据如下:
Date | Number
06-02-2012 | 2
06-05-2012 | 5
06-08-2012 | 5
如果我想在以下问题中包含在 DB 中找不到的所有日期,我该怎么做?:
Date | Number
06-02-2012 | 2
06-03-2012 | 0
06-04-2012 | 0
06-05-2012 | 5
06-06-2012 | 0
06-07-2012 | 0
06-08-2012 | 5
SELECT convert(varchar, MIN(DATEADD(wk, DATEDIFF(wk, 0, person.date), 0)), 1), Count(person.ID)
FROM [dbo].[Person] person
WHERE (DATEDIFF(D, person.date, @dateFrom) <=0 AND DATEDIFF(D, person.date, @dateTo) >=0)
GROUP BY DATEPART(WK, person.date)