title: Count based on condition in SQL Server
body: <p>Does anyone know how can I do a count in SQL Server based on condition.</p>
  
  <p>Example:</p>
  
  <p>How can I do a column count for records with name 'system', and total CaseID records in the table?</p>
  
  <p>Customer table</p>
  
  <pre><code>UserID     CaseID     Name
  1          100        alan
  1          101        alan
  1          102        amy
  1          103        system
  1          104        ken
  1          105        ken
  1          106        system  
  </code></pre>
  
  <p>The result will display like below:</p>
  
  <pre><code>UserID    TotalCaseID    TotalRecordsWithSystem
  1         7              2
  </code></pre>