title: MySQL - group by criterion AND count # of items that are grouped together - how?
body: <p>Is there a way to execute 1 query that would select all items ("SELECT * FROM <code>t-shirts</code>), group them by certain criterion ("GROUP BY <code>style</code>, <code>color</code>") but at the same time count the # of UNIQUE 'color' items that were grouped together? I can do that by cycling through each style->color and count the number of items, but I thought that perhaps there's an easier way of doing that.</p>
  
  <p>Thanks.</p>
  
  <p>P.S. Solved: remove <code>color</code> from GROUP BY, and used "COUNT (distinct color)": </p>
  
  <pre><code>SELECT *, COUNT (distinct color) FROM t-shirts GROUP BY style
  </code></pre>