title: Join on the first id where the date is the same or in the past
body: <p>How can I join Table1 on Table2 on opid, only if the table1's date &lt;= table2's date, AND it has no other matches?</p>
  
  <p>Here are some example tables:</p>
  
  <p>Table1</p>
  
  <pre><code>------------+-------+-----+
   date       | spend | opid|
  ------------+-------+-----+
   2019-07-05 | 5     |  1  |
  ------------+-------+-----+
   2019-07-07 | 4     |  2  |
  ------------+-------+-----+
   2019-07-08 | 6     |  2  |
  ------------+-------+-----+ 
  </code></pre>
  
  <p>Table2</p>
  
  <pre><code>+------------+-------+-----+
  | date       | users | opid|
  +------------+-------+-----+
  | 2019-07-06 | 100   |  1  |
  +------------+-------+-----+
  | 2019-07-08 | 200   |  2  | 
  +------------+-------+-----+ 
  </code></pre>
  
  <p>Expected Table</p>
  
  <pre><code>+------------+-------+-------+
  | date       | spend | users |
  +------------+-------+-------+
  | 2019-07-05 | 10    | 100   |
  +------------+-------+-------+
  | 2019-07-07 | 4     | null  |
  +------------+-------+-------+
  | 2019-07-08 | 6     | 200   |
  +------------+-------+-------+  
  </code></pre>
  
  <p>So 7-July doesn't join, because 8-July has already joined.</p>