title: How to count number of duplicated items in my from relational table
body: <p>I have <code>order</code> and a <code>product</code> tables. The order table looks like this:</p>
  <pre><code>uid  id  ref     order_id
  ---  --  ------  --------------
  1    3   abc.    112
  2    3   def     124
  </code></pre>
  <p>And the product table looke liks this</p>
  <pre><code>uid  id  sku     order_id
  ---  --  ------  --------------
  1    6   rs-123  112
  2    7   rs-123  112
  2    8   rs-abc  124
  </code></pre>
  <p>So I need a query where I get all the orders that have more than one identical sku like so:</p>
  <pre><code>order_id        sku          qty
  --------        ---------    --------
  112             rs-123       2
  </code></pre>
  <p>There could be orders with 2, 3 or more items with same sku. I do not want show any order that does not have duplicated skus</p>
  <p>I've tried this:</p>
  <pre><code>SELECT sku, order_id,
  COUNT(distinct sku) As Total
  FROM products
  GROUP BY order_id
  HAVING (COUNT(distinct sku) &gt; 1)
  </code></pre>
  <p>But it's not giving the expected results. Any ideas?</p>