title: Two SQL LEFT JOINS produce incorrect result
body: <p>I have 3 tables:</p>
  
  <pre><code>users(id, account_balance)
  grocery(user_id, date, amount_paid)
  fishmarket(user_id, date, amount_paid)
  </code></pre>
  
  <p>Both <code>fishmarket</code> and <code>grocery</code> tables may have multiple occurrences for the same user_id with different dates and amounts paid or have nothing at all for any given user.
  When I try the following query:</p>
  
  <pre><code>SELECT
       t1."id" AS "User ID",
       t1.account_balance AS "Account Balance",
       count(t2.user_id) AS "# of grocery visits",
       count(t3.user_id) AS "# of fishmarket visits"
  FROM users t1
  LEFT OUTER JOIN grocery t2 ON (t2.user_id=t1."id") 
  LEFT OUTER JOIN fishmarket t3 ON (t3.user_id=t1."id") 
  GROUP BY t1.account_balance,t1.id
  ORDER BY t1.id
  </code></pre>
  
  <p>It produces an incorrect results: <code>"1", "12", "12"</code>.<br>
  But when I try to <code>LEFT JOIN</code> to just one table it produces a correct results for either <code>grocery</code> or <code>fishmarket</code> visits, which are <code>"1", "3", "4"</code>.</p>
  
  <p>What am I doing wrong here?<br>
  I am using PostgreSQL 9.1.</p>