SELECT tp.ProjectName, tp.ProjectDescription, dev.FullName as 'Developer'
, o.FullName as 'Owner', tp.StartDate, tp.EndDate, tp.ProjectStatus,
tp.CompletionPct, Count(tb.ProjectID) as 'NumberofBugs'
FROM tblBTProject tp
LEFT JOIN tblBTBugs tb ON tp.ProjectID = tb.ProjectID
--Get user fullnames by ID
LEFT JOIN CollectionsOperationsControl.dbo.tblCOCUser as dev
ON tp.Developer = dev.CorpID
LEFT JOIN CollectionsOperationsControl.dbo.tblCOCUser as o
ON tp.Owner = o.CorpID
WHERE CAST(CONVERT(VARCHAR(10), tp.CreationDate, 101) AS DATETIME) BETWEEN @StartDate AND @EndDate
AND (tp.Developer IN (SELECT * FROM dbo.fnSplitList(LTRIM(RTRIM(@Developer)), ',')))
AND (tp.Owner IN (SELECT * FROM dbo.fnSplitList(LTRIM(RTRIM(@Owner)), ',')))
GROUP BY tp.ProjectID, tp.ProjectName, tp.ProjectDescription, dev.FullName, o.FullName, tp.StartDate, tp.EndDate,
tp.ProjectStatus, tp.CompletionPct
ORDER BY tp.ProjectID
在上面的代码中,我想返回tblBTBugs中tp.ProjectID的所有实例的计数(在tblBTProject的tp.ProjectID的连接上)我已经做了这个作为存储过程,但在我的报告服务中在“开发人员”和“所有者”上进行多次选择,它只显示每个“开发者”或“所有者”的一个实例,而不是所有匹配的记录。这是一个连接问题,它只返回每个实例的一个实例? 谢谢 附:我使用SQL Server 2005的存储过程。它的参数是@StartDate,@ EndDate,@Developer& @所有者 fnSplitList有助于SRSS中“Developer”和“Owner”的多值选择
在报告方面,我使用= JOIN(参数!Developer.Value,“,”)来分割记录