title: Joining two tables so that it returns only one row from right table and all from left table for each match
body: <p>I have a SQL query which performs a simple left join based on the given conditions which is as follows</p>
  
  <pre><code>SELECT
  a.Product,a.Grade,a.Term,a.Bid,
  a.Offer,b.Ltrd
  
  FROM CCS AS a 
  left  JOIN LTR AS b ON  b.Product=a.Product
  and b.Grade=a.Grade
  and b.Term=a.Term 
  </code></pre>
  
  <p>I have two tables CCS and LTR with following data</p>
  
  <pre><code>CCS Table
  
  Id Product Grade  Term  Bid Offer
  1  Xyz      A     Jan   20   30
  2  XYz      A     Jan   25   35
  3  abc      B     Feb   25   30
  
  LTR Table
  
  Id Product Grade  Term  Ltrd
  1  Xyz      A     Jan   500
  2  XYz      A     Jan   400
  </code></pre>
  
  <p>Upon running the above query it looks to match Product,Grade,Term and if all the three are equal, it performs left join and gives the following results</p>
  
  <pre><code>Product Grade Term Bid Offer Ltrd
  Xyz     A      Jan   20  30   500 
  Xyz     A      Jan   20  30   400
  XYz     A      Jan   25  35   500
  XYz     A      Jan   25  35   400
  abc     B      Feb   25   30  NULL
  </code></pre>
  
  <p>above returned 5 rows and I trying to get only three rows that are in the table <code>CCS</code> with the lowest value of the column <code>Ltrd(ie 400)</code> in <code>LTR</code> table as shown below </p>
  
  <pre><code>  Product Grade Term Bid Offer Ltrd
      Xyz     A    Jan   20  30   400
      Xyz     A    Jan   25  35   NULL
      abc     B    Feb   25  30   NULL
  </code></pre>
  
  <p>In the above results in <code>Ltrd</code> column I just want the lowest value taken from the match in <code>LTR</code> table and assign it to <code>Ltrd</code> in first row and make other one <code>NULL</code>(in the above case 2nd row) and in third row it of course <code>NULL</code> as there is no match in <code>LTR</code> table</p>