求助:帮我看下这个存储过程哪里不对
create procedure Th_EmployeeExamReport @year int
as
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
提示:消息 156,级别 15,状态 1,过程 Th_EmployeeExamReport,第 11 行
关键字 'from' 附近有语法错误。
------解决方案--------------------
多了个逗号
as 廉,
改为 as 廉
------解决方案--------------------
where eva_id=@year and d.assessed_id=s.assessed_id group by assessed_id) as 廉
from Th_EmployeeExam d) a