我正在使用以下过程来检索总数并presents
使用数据透视查询....我absents
想要然后SUM
Presents[P]
Absents[A]
calculate percentage
ALTER PROCEDURE [dbo].[GetAttendence](@Course_Id varchar(30), @Semester varchar(10))
AS
SELECT DISTINCT Enroll_Number, Course_Id, Semester, Isnull([P],0)
As Presents, Isnull([A],0) As Absents
FROM (SELECT Enroll_Number, Course_Id, Semester, Flag from Attendence ) ps
pivot(Count(Flag) for Flag in ([P],[A])) as pvt
WHERE Course_Id = @Course_Id and Semester = @Semester
这是Forula
为了实现......
总和 = 出席 + 缺席
百分比 = ((礼物/总和) * 100)