title: Student Result based on passed and failed remarks using SQL Server
body: <p>I have a table that stores students exam results. In that table I have a <code>nvarchar</code> column <code>REMARKS</code>; if obtained marks are less then passing marks, the system adds <code>Pass/Fail</code> to <code>Remarks</code> in that particular column. </p>
  
  <p>The problem is now I am showing whole result with total marks obtained and also display if a student has passed or failed, based on the a query like </p>
  
  <pre><code>If remarks = 'Fail' 
  </code></pre>
  
  <p>and fail is more than one subject in that exam than display Fail else Pass. I searched and tried a lot but no luck. can anyone please tell me how to get it done? </p>
  
  <p>Thanks!</p>
  
  <p>UPDATE: 
  Tried so far:</p>
  
  <pre><code>SELECT 
      StudentName,
      Year,
      ExamType,
      SUM(TotalMarks) AS TotalMarks,
      SUM(ObtainedMarks) AS ObtMarks  
  FROM 
      [dbo].[Exam]
  WHERE
      ExamType = @Type AND Year = @Year
  </code></pre>
  
  <p>Looking for a query something like:</p>
  
  <pre><code>CASE WHEN [Remarks] = 'Fail' and having count &gt; 1  THEN 'Fail' ELSE 'Pass' End as 'Status' 
  </code></pre>