I am performing a count based on a date range. Currently the query does return the correct result but I require additional information. In it\'s current form, the query show
I think will need to count CCount.BaselineID and use a left join
If you count on Tree.Type you would not get a zero on rows with no match
And you do know that date range will return zero
SELECT Tree.Type as 'Requirement Type'
, COUNT(CCount.BaselineID) as 'Number in Creation Range'
FROM [Tree]
INNER JOIN @ReqType As RT
on RT.Type = Tree.Type
INNER JOIN [Project_INFO]
ON [Project_INFO].[ProjectID] = [Tree].[Project_ID]
OUTER JOIN @CreationCount AS CCount
ON CCount.BaselineID=Tree.Baseline_ID
WHERE [Project_INFO].[Name] = 'Address Book'
AND CCount.Name = 'Current Baseline'
AND [Tree].[creationDate] >= ('2010-01-01')
and [Tree].[creationDate] < ('2020-01-01')
GROUP BY tree.Type