title: SQL with calculation based on multiple tables
body: <p>I have a simple DB with the following two tables.</p>
  
  <p>There is a one-to-many relationship between the <code>id</code> field in the sessions table
  and the <code>session_id</code> field in the candidates table.</p>
  
  <p>I'd like a query that will <code>SELECT * FROM SESSIONS</code>.</p>
  
  <pre><code>SESSIONS (TABLE)
  
  || id || title || max_candidates || description ||
  || 01 || fish  || 05             || some string ||
  || 02 || birds || 10             || some string ||
  
  CANDIDATES (TABLE)
  
  || session_id || user_id ||
  || 01         || user01  ||
  || 02         || user12  ||
  || 02         || user03  ||
  || 02         || user05  ||
  </code></pre>
  
  <p>However, in addition to returning the information from the sessions table,
  I'd also like it to return a <em>calculated column</em> named <code>avaliable_spaces</code>.</p>
  
  <p>I'd like to have this column return the number of avalaible spaces for a particular
  session based on (no of times <code>session_id</code> occurs in <code>CANDIDATES</code>) - (<code>max_candidates</code>)</p>
  
  <p>In the above example it would return (obviously minus the column <code>headders</code>);</p>
  
  <pre><code>|| id || title || max_candidates || description || avaliable_spaces ||
  
  || 01 || fish  || 05             || some string ||04                ||
  || 02 || birds || 10             || some string ||07                ||
  </code></pre>
  
  <p>Does this make sense? And if so, is it even possible!? (as you can probably guess)
  I'm an SQL noob and this is well beyond me!</p>