title: SQL Group By - Generate multiple aggregate columns from single column
body: <p>I would like to group by Company &amp; Date and generate count columns for 2 separate values (Flag=Y and Flag=N).
  Input table looks like this:</p>
  
  <pre><code>Company  Date   Flag
  ------- ------- -----
  001      201201  Y
  001      201201  N
  001      201202  N
  001      201202  N
  001      201202  Y
  </code></pre>
  
  <p>The output should look like this:</p>
  
  <pre><code>Company Date   Count_Y Count_N
  ------- ------ ------- -------
  001     201201  1       1
  001     201202  1       2
  </code></pre>
  
  <p>How can I write the SQL query?
  Any kind of help is appreciated! Thanks!</p>