sql server 2008 - SQL Conditional Statement in Where Clause -
i write following if statement in sql. of clause constructed, it's condition around statement i'm struggling with:
if @stuyear = 11 , (@teachinggroup = 'select all') , ([datacollection] = @datacollection) , ([name] = @subjectname) , (@subgroup='select all') , '' = case @subjectname when 'english' ks2en when 'mathematics' ks2ma else ks2av end , result not '[abu]%' , result <> '' else if @stuyear = 10 , @teachinggroup not 'select all' , ([datacollection] = @datacollection) , ([name] = @subjectname) , ([teachinggroup] = @teachinggroup) , @subgroup='select all' , '' = case @subjectname when 'english' ks2en when 'mathematics' ks2ma else ks2av end , result not '[abc]%' , result <> '' end if
simply replace if
where
, else if
or
, surround other conditions in paranthesis:
... (@stuyear = 11 , (@teachinggroup = 'select all') , ([datacollection] = @datacollection) , ([name] = @subjectname) , (@subgroup='select all') , '' = case @subjectname when 'english' ks2en when 'mathematics' ks2ma else ks2av end , result not 'a*' , result not 'a' , result not 'b' , result not 'u' , result not '' ) or (@stuyear = 10 , @teachinggroup not 'select all' , ([datacollection] = @datacollection) , ([name] = @subjectname) , ([teachinggroup] = @teachinggroup) , @subgroup='select all' , '' = case @subjectname when 'english' ks2en when 'mathematics' ks2ma else ks2av end , result not 'a*' , result not 'a' , result not 'b' , result not 'c' , result not '')
Comments
Post a Comment