title: filtering inside COUNT in sql server
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/582637/sql-equivalent-of-countif">SQL Equivalent of COUNTIF()</a>  </p>
  </blockquote>
  
  
  
  <p>Can I incorporate some kind of filtering mechanism inside COUNT itself, which I dont want to use in WHERE or JOINs of the query (since it is a part of large query in which there are other columns too which I dont want to get affected by where and join conditions).</p>
  
  <p>For example I can use case inside SUM</p>
  
  <pre><code>SUM(CASE WHEN work_status IN ('V','L') THEN shift_total_hours ELSE 0 END),
  </code></pre>
  
  <p>Can I do something like this in COUNT too, so that I would get count for particular rows only</p>
  
  <p>something like this: </p>
  
  <pre><code>COUNT(CASE WHEN work_status IN ('V','L') THEN &lt;should come in count&gt; ELSE &lt;exclude from count&gt; END)
  </code></pre>
  
  <p>many thanks.</p>