title: SQL Query - join on less than or equal date
body: <p>I'm having trouble figuring out how to format the following query. I want to take <code>Table A</code> and left join <code>Table B</code>. Not only on <code>a.country = b.country</code> but also on the <code>max start_date</code> that is less than equal to <code>join_date</code>.</p>
  
  <p><strong>Postgres (Redshift)</strong></p>
  
  <p><strong>Table A</strong></p>
  
  <pre><code>  ID      join_date     country          email     
   -----    -----------   ---------        ------
    124     '2013-10-03'     US         john@doe.com
    423     '2013-04-21'     CA         bob@doe.com
    412     '2013-03-30'     US         test@test.com
  </code></pre>
  
  <p><strong>Table B</strong></p>
  
  <pre><code>  start_date        country          joined_from
  -------------     -----------       --------------
  '2013-08-21'          US                google
  '2014-01-02'          CA                yahoo
  '2013-03-02'          CA                microsoft
  '2013-02-10'          US                facebook
  '2013-09-01'          US                yahoo
  </code></pre>
  
  <p><strong>End Result</strong></p>
  
  <pre><code>  ID     join_date     country      email         start_date     joined_from
  ------  -----------    ---------   ---------     ------------   -------------
   124    '2013-10-03'     US        john@doe.com   '2013-09-01'     yahoo
   423    '2013-04-21'     CA        bob@doe.com    '2013-03-02'    microsoft
   412    '2013-03-30'     US        test@test.com  '2013-02-10'    facebook
  </code></pre>