title: MySQL COUNT DISTINCT
body: <p>I'm trying to collect the number of distinct visits in my cp yesterday, then count them.</p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT
      DISTINCT `user_id` as user,
      `site_id` as site,
      `ts` as time
  FROM
      `cp_visits`
  WHERE
      ts &gt;= DATE_SUB(NOW(), INTERVAL 1 DAY)
  </code></pre>
  
  <p>For some reason this is pulling multiple results with the same site id....how do i only pull and count the distinct site_id cp logins?</p>