这个存储过程该怎么写
--------------------编程问答-------------------- create procedure Th_EmployeeExamReport @year intas
declare @aid int
select @aid=(select count(distinct user_id) from Th_EmployeeExam)
select a.eva_id,a.assessed_id,a.assessed_name,a.德,a.能,a.勤,a.语,a.廉,
cast(((a.德+a.能+a.勤+a.语+a.廉)*100)/84 as decimal(6,2)) as 最终得分
from
(select distinct
eva_id,
assessed_id,
assessed_name,
(select cast((CAST(SUM(exam_character) as decimal(6,2))/(@aid+1)) as decimal(6,2)) from Th_EmployeeExam s where eva_id=@year and d.assessed_id=s.assessed_id group by assessed_id) as 德,
(select cast((CAST(SUM(exam_ability) as decimal(6,2))/(@aid+1)) as decimal(6,2)) from Th_EmployeeExam s where eva_id=@year and d.assessed_id=s.assessed_id group by assessed_id) as 能,
(select cast((CAST(SUM(exam_diligent) as decimal(6,2))/(@aid+1)) as decimal(6,2)) from Th_EmployeeExam s where eva_id=@year and d.assessed_id=s.assessed_id group by assessed_id) as 勤,
(select cast((CAST(SUM(exam_language) as decimal(6,2))/(@aid+1)) as decimal(6,2)) from Th_EmployeeExam s where eva_id=@year and d.assessed_id=s.assessed_id group by assessed_id) as 语,
(select cast((CAST(SUM(exam_honest) as decimal(6,2))/(@aid+1)) as decimal(6,2)) from Th_EmployeeExam s where eva_id=@year and d.assessed_id=s.assessed_id group by assessed_id) as 廉
from Th_EmployeeExam d) a
注:assessed_id 被评分人ID。
像我上面这样写有什么不对
补充:.NET技术 , ASP.NET