以下のIF文をSQLで書きたいと思います。where句のほとんどは構築されていますが、私が苦労しているのはステートメントの周りの条件です:
if @StuYear = 11 then
AND (@TeachingGroup = 'Select All')
AND ([DataCollection] = @DataCollection)
AND ([Name] = @SubjectName)
AND (@Subgroup='Select All')
AND '' = CASE @subjectName WHEN 'English' THEN KS2en WHEN 'Mathematics' THEN KS2ma ELSE KS2av END
AND Result Not Like '[ABU]%' AND Result <> ''
else if @StuYear = 10 then
AND @TeachingGroup Not Like 'Select All'
AND ([DataCollection] = @DataCollection)
AND ([Name] = @SubjectName)
AND ([TeachingGroup] = @TeachingGroup)
AND @Subgroup='Select All'
AND '' = CASE @subjectName WHEN 'English' THEN KS2en WHEN 'Mathematics' THEN KS2ma ELSE KS2av END
AND Result Not Like '[ABC]%' AND Result <> ''
end if