title: Calculate group by Machines percentages in TSQL
body: <p>I want to calculate the percentages and counts from the sample dataset below.
  I have included the screenshot that contains the expected output.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Sample Data 
  Machine Environment   Status
  GA      PROD            Compliance
  GA      PROD            Non Compliance
  NY      NonProd       Compliance
  NY      NonProd       Non Compliance
  CA      PROD            Non Compliance
  CA      PROD            Compliance
  CA      PROD            Non Compliance
  CA      NonProd       Compliance
  WA      PROD            Non Compliance
  WA      NonProd       Compliance
  DN      PROD            Compliance
  DN      PROD            Non Compliance
  
  Expected output
  
  [![enter image description here][1]][1]
  
  Formula:            
  Prodcompliance%     Prod-Compliance/ProdTotal   
  NonProdCompliance%  NonProd-Compliance/NonProdTotal</code></pre>
  </div>
  </div>
  </p>
  <p><a href="https://i.stack.imgur.com/yPYEs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yPYEs.png" alt="enter image description here" /></a></p>