title: SQL Case Sensitive Group By
body: <h2>Intro</h2>
  
  <p>I have a table which is having a column "AccountCode" and other columns. There are few account codes which are same but differs being case-sensitive.
  Example:</p>
  
  <pre><code>AccountCode   OrderId
  ABC           O001
  ABC           O002
  abc           O003
  DEF           O004
  </code></pre>
  
  <h2>Objective</h2>
  
  <p>I want a query to have a group by on AccountCode column and get respective count. Expected output should be like </p>
  
  <pre><code>ABC      2
  abc      1
  DEF      1
  </code></pre>
  
  <p>I have tried using COLLATE Latin1_General_CS_AS but unable to get desired result.  </p>
  
  <p>Below query doesn't provide a case-sensitive output</p>
  
  <pre><code>select accountCode COLLATE Latin1_General_CS_AS, count(OrderId) 
  from &lt;&lt;TableName&gt;&gt; 
  group by accountCode
  </code></pre>