title: Subtract two columns of different tables
body: <p>I have two unrelated tables:</p>
  
  <pre><code>contribution(id,amount, create_at, user_id)
  
  solicitude(id, amount, create_at, status_id, type_id, user_id)
  </code></pre>
  
  <p>I need to subtract the sum of the amount of the contribution and of the solicitude from a user, but that result can't to be negative.</p>
  
  <p>How can I do this? Function or query?<br>
  I tried this query:</p>
  
  <pre><code>SELECT  sum(contribution.amount)
  - (SELECT sum(solicitude.amount) 
     FROM solicitude 
     WHERE user_id = 1 AND status_id = 1) as total
  FROM contribution 
  WHERE contribution.user_id = 1
  </code></pre>