title: Get latest record for each entry
body: <p>I have a table which says when a product was replaced for other and this other product may also appear in this table.</p>
  
  <p>I want to know how can I write a query where given a product, I get the latest available (replaced) product.</p>
  
  <p>Example:</p>
  
  <pre><code>    Product_From   Product_To
      -------------------------
      A              E
      A              D
      B              F
      C              B
      D              F
      D              G
  </code></pre>
  
  <p>How would be a query to get the following output:</p>
  
  <pre><code>    Product_From   Product_Final
      -------------------------
      A              E
      A              F
      A              G
      B              F
      C              F
      D              F
      D              G
  </code></pre>
  
  <p>The product A was replaced for product D and E but product D was replaced for F and G so product A has products E, F &amp; G as "final products".</p>
  
  <p>The problem is that products can have different replacement entries thus I don't know how many JOINS I need... </p>