title: How to attribute value to row based on nearest date
body: <p>I'm attempting to attribute a value for &quot;revenue&quot; to a row based on the closest run_date, looking forwards in time. I'm using a date range as a join condition to only join rows within a 10 day &quot;lookahead&quot; period with the below....</p>
  <pre><code>SELECT 
  * 
  FROM t1 
    INNER JOIN t2 ON t1.id = t2.id 
    AND t2.date BETWEEN t1.run_date AND DATE_ADD(t1.run_date, INTERVAL 10 DAY)
  </code></pre>
  <p>The far right table is what I'm trying to achieve:</p>
  <p><a href="https://i.stack.imgur.com/NVRHL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NVRHL.png" alt="enter image description here" /></a></p>
  <p>Does anybody have any advice as to how to get my intended result? (Far right table of the image)</p>
  <p>I have a SQL fiddle <a href="http://sqlfiddle.com/#!9/9e44f7/1" rel="nofollow noreferrer">here</a> if anyone is interested in helping out.</p>