title: How to join get results per day without looping in stored procedure
body: <p>I am so sorry. I did not ask the question correctly. So here it is again:</p>
  
  <p>I have a table containing number of posts, their destinations and their retrieval dates. What I want to do is for a date range and for each date in the range, find the latest number of posts for each destination that is earlier than the date. This needs to be done in a stored procedure and not looping through the date range. Is it possible? Thanks.</p>
  
  <p>For example:</p>
  
  <pre><code>Destination  RetrievalDate       NumberOfPosts
  -----------  ------------------  -------------
  A            11/1/2011 12:00 AM  1
  A            11/1/2011 1:00 AM   5
  A            11/1/2011 5:00 AM   6
  B            11/1/2011 12:00 AM  0
  B            11/1/2011  4:00 AM  2
  C            10/20/2011 5:00PM   1
  A            11/2/2011 12:00 AM  8
  A            11/2/2011 2:00 AM   9
  B            11/2/2011 12AM      3
  </code></pre>
  
  <p>For example, in the above table, if the date range is 11/1/2011 - 11/3/2011, I would get </p>
  
  <pre><code>Destination  ReportDate  NumberOfPosts
  -----------  ----------  -------------
  A            11/1/2011   6
  B            11/1/2011   2
  C            11/1/2011   1
  A            11/2/2011   9
  B            11/2/2011   3
  C            11/2/2011   1
  A            11/3/2011   9
  B            11/3/2011   3
  C            11/3/2011   1
  </code></pre>