title: Need to filter data on condition
body: <p>I have sales data. the orders get sales codes, like if the order came from web chat. We are dealing with orders which had sales rep involved, not automatic online order.</p>
  
  <p>Each such order will get a code of 001. then also will get for example
  'BCS'</p>
  
  <p>so we would have data as</p>
  
  <pre><code>order#   Ord.date  ord.time  Amt etc.  sales code
  
  12345     05/18/15  090000    100.00       001
  12345     05/18/15  100000    100.00        BCS
  </code></pre>
  
  <p>so this is fine, the problem I am having in my crystal report is when the enter a 3rd code. The app is not stopping. but so when we have  a 3rd row</p>
  
  <pre><code>12345     05/18/15   140000    100.00        BCQ
  </code></pre>
  
  <p>so this 3rd row is throwing off my CR totals.</p>
  
  <p>I need to create a view on this data that will return all 001 and then only the first of a non 001 code, meaning according to the lower date/time. note that is entirely possible for there to be various dates, but we would want the earlier one only.</p>
  
  <p>I am not sure how to make such a condition in SQL Query. So in our example we want the 001 row and the BCS because the time and date is earlier than the 3rd row.</p>