title: SQL query Join with datetime inside
body: <p>I need to manage some data and retrieve a result I'm not able to do.</p>
  
  <pre><code>Table1
  id int
  idcat int (related to the table2)
  tt varchar
  dt datetime
  
  Table2
  idcat int
  days int
  </code></pre>
  
  <p>what I need is to retrieve <strong>ALL</strong> <code>table1</code> record that are not older than days related to each <code>category</code> (<code>idcat</code>).</p>
  
  <p>Thanks,
  A.</p>