title: filter postgresql query result
body: <p>I have multiple tables that need to be merged into one. </p>
  
  <pre><code>SELECT name, SUM(money) AS MONEY FROM transactions
  JOIN results ON transactions.id = results.id
  JOIN more ON results.per_id = more.per_id
  GROUP BY name
  </code></pre>
  
  <p>The output is person's name (first column) and person's money (second column).</p>
  
  <pre><code>name | money
  aaron  1220
  mike   800
  john   200
  kate   600
  </code></pre>
  
  <p>Now I try to filter the result by a money amount, i.e. to show results for people with "Sum(money) > 500"</p>
  
  <p>for that reason I tried putting "WHERE money > 500 GROUP BY name" however the output was wrong (aaron 1000, mike 610, etc..).</p>
  
  <p>how do you write a query to filter the <strong>last/ending</strong> result?</p>