Hi! I need to figure out if a student is proficient.I have the following query:declare @test char(1) --type of testdeclare @subj varchar(5) --subject, possible values: rdng, write, math, alldeclare @sql varchar(3000) --querydeclare @flag char(1) --indicates either search is for Proficient or non Proficient, values: Y Nset @test = 'C'set @subj = 'all'set @flag = 'Y'set @sql = 'Select * from RollupScores whereCASE WHEN ''' + @subj + ''' = ''rdng'' THEN ReadingProf WHEN ''' + @subj + ''' = ''write'' THEN WritingProf WHEN ''' + @subj + ''' = ''math'' THEN MathProfELSE 1 = 1ENDif (''' + @subj + ''' <> ''all'') BEGIN CASE WHEN ' + @flag + ' = ''Y'' THEN IN (''AP'', ''BP'') ELSE NOT IN (''AP'', ''BP'') ENDEND'print(@sql)exec(@sql)which gives me the following constructed query with errors:Select * from State_RollupScores whereCASE WHEN 'all' = 'rdng' THEN ReadingProf WHEN 'all' = 'write' THEN WritingProf WHEN 'all' = 'math' THEN MathProfELSE 1 = 1ENDif ('all' <> 'all') BEGIN CASE WHEN Y = 'Y' THEN IN ('AP', 'BP') ELSE NOT IN ('AP', 'BP') ENDENDServer: Msg 170, Level 15, State 1, Line 6Line 6: Incorrect syntax near '='.Server: Msg 156, Level 15, State 1, Line 10Incorrect syntax near the keyword 'CASE'.What am I doing wrong and how can I reach my goal?Thank you.