title: How to combine a SELECT query and a COUNT(*) query?
body: <p>I have the following query</p>
  
  <pre><code>SELECT 
            c.cd,
            c.c_id 
  FROM
            f f 
            INNER JOIN s s 
                      ON s.s_id = f.s_id 
            INNER JOIN c c 
                      ON c.c_id = s.c_id 
  WHERE f.m_id = 2 
            AND f.deleted = 'no' 
  GROUP BY s.c_id 
  ORDER BY f.update_datetime DESC ;
  </code></pre>
  
  <p>Which returns a sample result set:</p>
  
  <pre><code>c.cd    c.c_id
  moot    4
  derp    5
  </code></pre>
  
  <p>I have another query based on the <code>c.c_id</code> of the above result set which iterates for each record in the above result set:</p>
  
  <pre><code>SELECT COUNT(*) as totals FROM s
  WHERE c_id =?
  AND status='good';
  </code></pre>
  
  <p>returns <code>7</code> when <code>c_id=4</code> and returns <code>20</code> when <code>c_id=5</code></p>
  
  <p>Is there any way I can combine the two queries to form a result set like this?</p>
  
  <pre><code>c.cd    c.c_id  totals
  moot    4       7
  derp    5       20
  </code></pre>