title: SQL - How to join on similar (not exact) columns
body: <p>I have two tables which get updated at <em>almost</em> the exact same time - I need to join on the datetime column.</p>
  
  <p>I've tried this:</p>
  
  <pre><code>SELECT *
  FROM A, B
  WHERE ABS(DATEDIFF(second, A.Date_Time, B.Date_Time)) = (
      SELECT MIN(ABS(DATEDIFF(second, A.Date_Time, B2.Date_Time)))
      FROM B AS B2
  )
  </code></pre>
  
  <p>But it tells me:</p>
  
  <blockquote>
    <p>Multiple columns are specified in an aggregated expression containing an outer reference.  If an expression being aggregated contains an outer reference, then that outer reference must be the only column referenced in the expression.</p>
  </blockquote>
  
  <p>How can I join these tables?</p>