title: MySQL GROUP BY two columns
body: <p>I'm trying to group by multiple columns here - one on each table.<br>
  It's a scenario where I want to find the top portfolio value for each client by adding their current portfolio and cash together but a client may have more than one portfolio, so I need the top portfolio for each client.</p>
  
  <p>At the moment, with the code below I'm getting the same clients multiple times for each of their top portfolios (it's not grouping by client id).</p>
  
  <pre><code>SELECT clients.id, clients.name, portfolios.id, SUM ( portfolios.portfolio +  portfolios.cash ) AS total
  FROM clients, portfolios
  WHERE clients.id = portfolios.client_id
  GROUP BY portfolios.id, clients.id
  ORDER BY total DESC
  LIMIT 30 
  </code></pre>