title: query about avg's max
body: <p>I have this query: Find the branch and branche's city with the biggest avg amounts for product 'beta600' between 2010-2014.<br>
  I execute this code but I get no results. It takes about 10 min to execute and it gives null. Can u help?</p>
  
  <pre><code>SELECT DISTINCT branch_code,branch_city, AVG(trn_amount)) AS max_avg
  FROM branches,transactions,products,accounts
  WHERE branches.branch_code = accounts.branch_code AND 
  products.product_code = accounts.product_code AND 
  accounts.account_id = transactions.account_id AND 
  product_name = 'Beta600' AND
  trn_date &gt; '31/12/2009' AND trn_date &lt; '1/1/2015'
  GROUP BY branch_code,branch_city
  ORDER BY max_avg
  LIMIT 1;
  </code></pre>