title: Cross tables in a loop
body: <p>I have these two tables</p>
  
  <p>ItemMov</p>
  
  <pre><code>Item  Date
  A     2018-03-31
  A     2018-03-30
  A     2018-03-25
  B     2018-03-28
  B     2018-03-29
  </code></pre>
  
  <p>and DateTable</p>
  
  <pre><code>Date
  2018-03-31
  2018-03-30
  2018-03-29
  2018-03-28
  2018-03-27
  2018-03-26
  2018-03-25
  </code></pre>
  
  <p>What i need is to have a sort of cross product between those two but limited to the earlest date for each item.
  Initially i used simple cross product.</p>
  
  <pre><code>select distinct t.Item, f.Date from ItemMov t cross join DateTable f
  </code></pre>
  
  <p>getting this</p>
  
  <pre><code>Item       Date
   A    2018-03-31
   A    2018-03-30
   A    2018-03-29
   A    2018-03-28
   A    2018-03-27
   A    2018-03-26
   A    2018-03-25
   B    2018-03-31
   B    2018-03-30
   B    2018-03-29
   B    2018-03-28
   B    2018-03-27
   B    2018-03-26
   B    2018-03-25
  </code></pre>
  
  <p>Of course this crossing brings dates early than the first date for some items, like B.
  The desired output should be something like that but limited to the min(date) for each item. So, is there a why of doing this with crossing tables or should a use some sort of loop?</p>
  
  <p>Desired output</p>
  
  <pre><code>Item       Date
   A    2018-03-31
   A    2018-03-30
   A    2018-03-29
   A    2018-03-28
   A    2018-03-27
   A    2018-03-26
   A    2018-03-25
   B    2018-03-31
   B    2018-03-30
   B    2018-03-29
   B    2018-03-28
  </code></pre>