title: SQL COUNT() / LEFT JOIN?
body: <p>I have three tables: calls, attachments and notes and I want to display everything that's in the calls table, but also display whether a call has attachments and whether the call has notes. - by determining if there is an attachment or note record with a call_id in it. There could be notes and attachments, or there may not be but I would need to know.</p>
  
  <p>Tables structure:</p>
  
  <p>calls:</p>
  
  <pre><code>call_id  |  title  |  description  
  </code></pre>
  
  <p>attachments:</p>
  
  <pre><code>attach_id  |  attach_name  |  call_id  
  </code></pre>
  
  <p>notes:</p>
  
  <pre><code>note_id  |  note_text  |  call_id  
  </code></pre>
  
  <p>If I write:</p>
  
  <pre><code>SELECT c.call_id
       , title
       , description
       , count(attach_id) 
  FROM calls c 
  LEFT JOIN attachments a ON c.call_id = a.call_id 
  GROUP BY c.call_id
         , title
         , description
  </code></pre>
  
  <p>to give me a list of all calls and the number of attachments.</p>
  
  <p>How can I also add in a column with the number of notes or a column which indicates that there is notes?</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks.</p>