title: Oracle: Returning the earliest date
body: <p>I have a stored procedure which I use to return the earliest available date in a column of dates. I need to only return the earliest, and currently am using date arithmetic to reduce the number of returned rows. However, doing it this way, my procedure gets stuck in a loop of the first two top returned values, meaning I have several rows which are never read. Could somebody please let me know where I need to use the MIN function in the following <em>WHERE</em> clause, please? Thanks:</p>
  
  <pre><code>SELECT        **COLS**                
  INTO          **VARS**
  FROM          **TABLE**
  
  INNER JOIN    **TABLE TO JOIN**
  ON            **JOIN TARGET**
  
  WHERE         ROWNUM = 1 AND LASTREADTIME &lt; SYSDATE - (30/86400) 
  
  ORDER BY      LASTREADTIME DESC;
  </code></pre>