0

我在 mvc3 工作,我需要一些帮助

在这里,我有一些表格,例如(BugId)

BugID 标题 描述 ProjectId 版本 BuildNumber EmployeId CategoryID CreatedDate SeverityID PriorityID ReleasePhaseID TypeID

2 银行银行应用程序 1 新版本 新版本号 1 1 00:00:00.00 1 1 1 1

(项目表)

==================================================== =====

 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

6 电子商务 这是活跃的金融项目

RealesePhase(表格)

==================================================== ===================

 ReleasePhaseID    ReleasePhase

1       DEV
2       QA
3       Alpha
4       Beta

5 直播

状态(表)

==================================================== =

ToStatusId        Tostatus

1       New
2       Assigned
3       Fixed
4       Re-Opened
5       Closed
6       Deffered

7 不是虫子

Bughistory(表)

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(dropdown) 和 (ReleasePhase) (open)(close)(fixedBy)

在 Bugs 表中 Bugs 将从中记录(插入),所以现在我们必须选择 Project Name & ReleasePhase 作为下拉列表,如果我们选择项目名称,我应该得到我们拥有的 Bug 数量(计数)

从它喜欢(视图)应该这样

==================================================== ====================

项目名称 RealesePhase openBugs ClosedBugs fixedBy

                 1         New         EmployeName
                 2         Assigned    EmployeName
                 3         Fixed       EmployeName
                 4         Re-Opened   EmployeName

==================================================== =====================

所以请帮我写一个查询计数并显示员工插入了多少错误,释放了多少,关闭了多少

提前致谢

4

1 回答 1

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
于 2012-08-31T10:36:19.993 回答