title: Incorrect syntax near the keyword 'then' in if statement
body: <p>Im having an issue while running this query its showing "Incorrect syntax near the keyword 'then'" and the datatype of CorrectAnswer and AnswerID are varchar(10).</p>
  
  <pre><code>   select  T.[AssociateID],  
             T.[QuestionID],  
             T.[Result]  
     from
          AssociateAssessmentTransaction T  
          left join   
          AssessmentQuestions A  
          on  T.[QuestionID]=T.[QuestionID]  
          group by T.[AssociateID],
                   T.[QuestionID],
                   T.[Result]
          if(A.[CorrectAnswer] = T.[AnswerID]) 
            then 
            T.[Result] = 1;
          else  
            T.[Result] = 0;
          end if    
  </code></pre>