我在mvc3工作,我需要一些帮助
错误ID标题说明ProjectId版本BuildNumber EmployeId CategoryID CreatedDate SeverityID PriorityID ReleasePhaseID TypeID
(项目表)
=============================================== ======
Projectid ProjectName Description Status
1 Finance This is Finance Project Active
2 Uniformatic This is Finance Project Active
3 ProDuct This is Finance Project InActive
4 Cloud This is Finance Project INActive
5 Banking This is Finance Project Progress
RealesePhase(表格)
=============================================== =====================
ReleasePhaseID ReleasePhase
1 DEV
2 QA
3 Alpha
4 Beta
Tostatus(表)
=============================================== ====
ToStatusId Tostatus
1 New
2 Assigned
3 Fixed
4 Re-Opened
5 Closed
6 Deffered
BugHistoryID BugID FixedByID AssignedTo Resolution FromStatus ToStatus
5 2 1 1 this is my banking New New
7 2 1 1 this assignto res km,l
=============================================== ================================================== =====
这里我有这些表现在我必须写一个查询来选择ProjectName(下拉列表) 和(ReleasePhase)从它(开放)(关闭)(fixedBy)
在Bugs表中的错误将从中记录(插入),所以现在我们必须选择Project Name&如果我们选择项目名称,ReleasePhase作为下拉列表我应该得到我们拥有的Bugs No(计数)
从它开始就像 (查看)应该喜欢这个=============================================== ======================
ProjectName RealesePhase openBugs ClosedBugs fixedBy
1 New EmployeName
2 Assigned EmployeName
3 Fixed EmployeName
4 Re-Opened EmployeName
=============================================== =======================
所以plz帮我写了一个查询计数,并显示了Employee插入了多少bug以及释放了多少bug以及关闭了多少
提前致谢
答案 0 :(得分:1)
你最好使用存储过程...我认为你需要根据你的状态表和Releasephase和ProjectId来计算错误。这是我想通过看到你的问题希望它可以帮助你....
Create procedure [dbo].[ProjectReports]
(
@ProjectID int,
@ReleasePhaseID int
)
as
begin
select distinct projectName,ReleasePhase,
(Select COUNT(1) from Bugs where ProjectId=a.ProjectId and ReleasePhaseID=a.ReleasePhaseID and
bugid in (select BugID from BugHistory where [status]='New')) as Newbugs,
(Select COUNT(1) from Bugs where ProjectId=a.ProjectId and ReleasePhaseID=a.ReleasePhaseID and
bugid in (select BugID from BugHistory where [status]='Assigned')) as Assignedbugs,
(Select COUNT(1) from Bugs where ProjectId=a.ProjectId and ReleasePhaseID=a.ReleasePhaseID and
bugid in (select BugID from BugHistory where [status]='Fixed')) as Fixedbugs,
(Select COUNT(1) from Bugs where ProjectId=a.ProjectId and ReleasePhaseID=a.ReleasePhaseID and
bugid in (select BugID from BugHistory where [status]='Re-Opened')) as Reopenedbugs,
(Select COUNT(1) from Bugs where ProjectId=a.ProjectId and ReleasePhaseID=a.ReleasePhaseID and
bugid in (select BugID from BugHistory where [status]='Closed')) as Closedbugs,
(Select COUNT(1) from Bugs where ProjectId=a.ProjectId and ReleasePhaseID=a.ReleasePhaseID and
bugid in (select BugID from BugHistory where [status]='Deffered')) as Defferedbugs,
(Select COUNT(1) from Bugs where ProjectId=a.ProjectId and ReleasePhaseID=a.ReleasePhaseID and
bugid in (select BugID from BugHistory where [status]='Not a Bug')) as NotaBug
from Bugs a
inner join Projects p on p.ProjectId=a.ProjectId
inner join ReleasePhase Rp on rp.ReleasePhaseID=a.ReleasePhaseID
where a.ProjectId=@ProjectID and a.ReleasePhaseID=@ReleasePhaseID
end