title: SQL Join on Nearest less than date
body: <p>Normally I would just do this in the code itself, but I am curious if this can be accomplished efficiently in TSQL.</p>
  
  <pre>Table 1 
  Date - Value
  </pre>
  
  <pre>Table 2
  Date - Discount
  </pre>
  
  <p>Table 1 contains entries for each day.  Table 2 contains entries only when the discount changes.  A discount applied to a value is considered valid until a new discount is entered.</p>
  
  <p>Example data:</p>
  
  <pre>Table 1  
  1/26/2010 - 10  
  1/25/2010 - 9  
  1/24/2010 - 8  
  1/24/2010 - 9   
  1/23/2010 - 7    
  1/22/2010 - 10  
  1/21/2010 - 11
  </pre>
  
  <pre>
  Table 2
  1/26/2010 - 2  
  1/23/2010 - 1  
  1/20/2010 - 0  
  </pre>
  
  <p>What I need returned is the following: <code>T1 Date - T1 Value - T2 Discount</code></p>
  
  <p>Example data:</p>
  
  <pre>
  1/26/2010 - 10 - 2    
  1/25/2010 - 9  - 1  
  1/24/2010 - 8  - 1  
  1/24/2010 - 9  - 1  
  1/23/2010 - 7  - 1    
  1/22/2010 - 10 - 0  
  1/21/2010 - 11 - 0  
  </pre>
  
  <p>Possible or am I better off just continuing to do this in the code?</p>