title: SQL - Adding a count if Statement
body: <p>I'm a relatively new SQL user so please bear with me :)</p>
  
  <p>My current query is as follows...</p>
  
  <pre><code>SELECT DISTINCT 
    DMA.Name, 
    CLI.CNum, 
    CLI.LNum, 
    CLI.TSC, 
    CLI.FromDate, 
    CLI.ToDate
  FROM PurchasedSites INNER JOIN
    CLI ON PS.CNum = CLI.CNum INNER JOIN
    S ON PS.SID = S.SID INNER JOIN
    DMA ON S.DMA = DMA.ID INNER JOIN
    PSM ON PS.PSID = PSM.PSID INNER JOIN
    C ON CLI.CNum = C.CNum
  WHERE (PSM.MT_bmID = 10) AND 
    (CLI.FromDate &lt;= '2013-03-31') AND 
    (CLI.ToDate &gt;= '2013-03-01') AND 
    (S.DMA IN ('134', '113', '38', '147', '169', '24', '50', '198', '9', '55')) AND 
    (C.CS LIKE 'Active') AND 
    (PS.CNum Like 'C%') AND 
    (CLI.TSC &gt;= 1)
  </code></pre>
  
  <p>I would like it to COUNT the number of S.SID (or it could be PS.SID - it's the same data) if PS.DC = 1.  If there are PS.DC = 1, then it can return a number of 0.  </p>
  
  <p>I'm not sure where to fit this in or have it written properly.  Current results look like...</p>
  
  <pre><code>Name              CNum     LNum   TSC   FromDate     ToDate
  Detroit, MI       C147157   22     2    2013-03-18   2013-06-10 
  Atlanta, GA       C146525   112    2    2013-01-28   2013-03-03 
  Washington, DC    C146538   20     1    2013-02-06   2013-03-05
  Los Angeles, CA   C146119   45     3    2013-01-01   2013-11-30 
  </code></pre>
  
  <p>Thoughts?</p>