title: getting non-distinct results from a distinct mysql query
body: <p>Right, another question on queries (there must be a syntax guide more helpful than mySQL's manual, surely?)</p>
  
  <p>I have this query (from another helpful answer on SO)...</p>
  
  <pre><code>SELECT DATE_FORMAT(`when`, '%e_%c_%Y')date, COUNT(`ip`) AddressCount FROM `Metrics` WHERE `ID` = '1' GROUP BY DATE(`when`)
  </code></pre>
  
  <p>I now want to do a similar query to get unique/distinct results for the IPs... i.e. unique visitors per date. My query was this...</p>
  
  <pre><code>SELECT DATE_FORMAT(`when`, '%e_%c_%Y')date, COUNT(distinct `ip`) AddressCount FROM `Metrics` WHERE `ID` = '1' GROUP BY DATE(`when`)
  </code></pre>
  
  <p>However, that returns a repetition of dates, though different quantities of Addresscount...</p>
  
  <pre><code>date    AddressCount
  29_6_2009   1
  30_6_2009   1
  29_6_2009   1
  30_6_2009   1
  29_6_2009   1
  NULL    1
  15_5_2009   1
  14_5_2009   2
  NULL    3
  14_5_2009   4
  15_5_2009   1
  26_6_2009   1
  29_6_2009   1
  26_6_2009   1
  15_5_2009   1
  26_6_2009   1
  29_6_2009   1
  </code></pre>
  
  <p>Any ideas on where I'm going wrong?</p>