title: 'NOT GREATER THAN' condition Mysql
body: <p>I have a mysql table with columns <code>userid</code> and <code>createdon</code> where <code>createdon</code> column has <code>DATE</code> datatype.</p>
  
  <pre><code>---------------------------------------------------------------------------------
  ID                      UserId                         CreatedOn
  1                         65                           2013-06-13 
  2                         54                           2013-07-03
  3                         34                           2013-08-23
  4                         65                           2013-09-13 
  5                         89                           2013-09-13
  </code></pre>
  
  <p>Now I want the userids where <strong>last</strong> createdon was before 2013-09-08. The correct answer will be userids 54,34</p>
  
  <p>Using</p>
  
  <pre><code>select userid from table  where createdon &lt;'2013-09-08'
  </code></pre>
  
  <p>returns 65,54,34 and usind</p>
  
  <pre><code>select userid from table where userid notin (select userid from table where createdon &gt; '2013-09-07')
  </code></pre>
  
  <p>takes a lot of time. </p>
  
  <p>How to get the rows where last createdon  &lt; 2013-09-08</p>