title: Get 0 value from a count with no rows
body: <p>I have SELECT:</p>
  <pre><code>SELECT c FROM (
      SELECT &quot;candidate_id&quot; as id, count(&quot;candidate_id&quot;) as c
      FROM &quot;Applicaions&quot;
      GROUP BY &quot;candidate_id&quot;
  ) as s WHERE id= _SOME_ID_;
  </code></pre>
  <p>But this only returns a value if <code>count &gt; 0</code>. If <code>count = 0</code> it returns nothing. How can I get <code>0</code> for a &quot;Candidate&quot; that doesn't have any application?</p>
  <p>There is table &quot;Candidates&quot;.<br />
  I need to get 0 if candidate has no applications or does not exist.</p>
  <h3>EDIT</h3>
  <p>I have now:</p>
  <pre><code>SELECT COALESCE ((SELECT count(&quot;candidate_id&quot;) as c
  FROM &quot;Applicaions&quot; WHERE &quot;candidate_id&quot;=_SOME_ID_
  GROUP BY &quot;candidate_id&quot;), 0);
  </code></pre>
  <p>It works perfectly. But is it possible to write it simpler or is this the best solution? Should I create any indexes?</p>