title: SQL Server Count for multiple conditions
body: <p>for the table below, how can I write a subquery for my select query 
  so that I can return a flag column when the Inv = Esc for a given Num ?</p>
  
  <p>In the example below, the second row is a match as well as the fifth row.
  Tried but keep getting boggled.  Thanks.</p>
  
  <p>**Additionally, there should be only one Flag for each Num.</p>
  
  <pre><code>    Num  |  Name   |Inv |Esc|Flag
  1)  *785*   | AB7851     |155   |496  
  2)  *785*   | AB7852     |**496 |496**  |**Hit**
  3)  *785*   | AB7853     |518   |496  
  4)  *785*   | AB7854     |769   |496  
  5)  236 | AB785Q     |**155 |155**      |**Hit**
  6)  236 | AB785R     |496   |155  
  7)  236 | AB785S     |518   |155  
  8)  236 | AB785T     |747   |155  
  9)  236 | AB785U     |769   |155  
  </code></pre>