title: Select count of dates older than x days
body: <p>My example table:</p>
  
  <pre><code>+----------+---------------------+
  | username |        time         |
  +----------+---------------------+
  | john     | 2013-02-04 17:39:43 |
  | john     | 2013-02-03 00:21:31 |
  | peter    | 2013-02-02 15:04:53 |
  | grace    | 2013-02-02 03:57:43 |
  | peter    | 2013-02-03 15:36:15 |
  +----------+---------------------+
  </code></pre>
  
  <p>This table registers activities from users. I need to count the number of users whose last activity date was more than 30 days ago.</p>
  
  <p>I had developed this query:</p>
  
  <pre><code>SELECT
    username,
    MAX(time),
    DATEDIFF(NOW(), MAX(time)) as diff
  FROM tracking
  GROUP BY username
  HAVING diff &gt; 30
  </code></pre>
  
  <p>Which effectively returns the list of users whose activities are more than 30 days ago, along with the date of that last activity.</p>
  
  <p>But I need the <strong>count</strong> of this list, not the list itself. Is there any way I can count the list?</p>
  
  <p><strong>NOTES:</strong></p>
  
  <ul>
  <li>I can only rely on <strong>SQL</strong> statements, I can't use <strong>PHP</strong> or <strong>ASP</strong> or anything else.</li>
  <li>I can't use <strong>STORED PROCEDURES</strong>.</li>
  <li>I don't need performance, as this statement will only be run once in a while.</li>
  </ul>