title: Get last record making multiple searches in the same table
body: <p>I have one table called <code>Products</code>.</p>
  
  <p><strong>Fields</strong></p>
  
  <ul>
  <li>product_id</li>
  <li>Type (IN or OUT)</li>
  <li>Date (date of registration)</li>
  </ul>
  
  <p>I have several entries in the table, with entries and product outputs with their respective dates.</p>
  
  <p>How do I find products that do not have <code>OUTPUT</code> movement after the <code>LAST ENTRY</code>?</p>
  
  <p>I already tried:</p>
  
  <pre><code>SELECT Products.product_id, Products.Type, MAX(Products.Date) 
  FROM Products PRODUCTS_1 
  LEFT OUTER JOIN Products PRODUCTS 
    ON PRODUCTS_1.Product_Id = PRODUCTS.Product_Id 
    AND PRODUCTS_1.Type='O'} 
  WHERE (PRODUCTS.Type='I') 
    AND (PRODUCTS_1.Date&gt;PRODUCTS.Date) 
  GROUP BY Products.product_id, Products.Type;
  </code></pre>