I have the below query with a date range between '09/01/16' and '12/30/16'. In the attached picture results are only for September and October, I would like to still show November and December (or to the given date2
range) with a count of 0
How can I accomplish this?
declare @date1 date = '09/01/16'
declare @date2 date = '12/30/16'
select
count(distinct w.wkid) as WksCount
,DATENAME(MONTH, r.date) as [month]
,year(r.date) as [year]
from
Workshop w
left join Reservation r on r.wkid=w.wkid
left join Registration reg on reg.wkid=w.wkid
where
r.date between @date1 and @date2
group by
DatePart(Month, r.date)
,DateName(Month, r.date)
,year(r.date)
order by
year(r.date)
,DatePart(Month, r.date)
I