嘿...我有這個數據庫,我需要創建一個函數,返回通過一個主題的學生的百分比,但我不知道我做錯了什麼... 請問你能幫幫我嗎???這是我的圖,這裏是我的功能...我不知道這個功能有什麼問題
create function fnPassedStudents(@Semester varchar(7),@CodSubjects varchar(5))
returns @Passed
TABLE (
Semester varchar(7),
Cod_Subjects varchar(5),
Name_Subjects varchar(80),
Nro_Students int,
Nro_Passed float,
Nro_Failed float,
PercentagePassed varchar(4))
as
begin
declare @NroPassed float
select @NroPassed = count(M.Cod_Student)
from Matricula M inner join Subjects A on M.Cod_Subjects = A.Cod_Subjects
Where [email protected] and M.Cod_Subjects = @CodSubjects and M.Grade>=10
insert into @Passed
select M.Semester, A.Cod_Subjects, A.Name_Subjects, COUNT(M.Cod_Student) as Total,
@NroPassed as Passed, (COUNT(M.Cod_Student) - @NroPassed) as Failed,
((@NroPassed * 100)/(count(M.Cod_Student))) as PercentagePassed
from Matricula M inner join Subjects A on M.Cod_Subjects = A.Cod_Subjects
Group by M.Semester, A.Cod_Subjects, A.Name_Subjects
return
end
go
我不確定是否該信息就足夠了...但是請耐心I'll添加您需要什麼...謝謝! !
它在做什麼或不做什麼?它會崩潰嗎?給出錯誤?或者只是不做你的期望? – Jason 2011-03-14 02:02:55