title: Sql Server Self JOIN (pushing column values down)
body: <p>I am asked to do the following: 
  "CycleStartDate needs to be the BillDate from the previous BillDate record. If a previous record does not exist, you should use the most recent CycleEndDate from the DataTime table"</p>
  
  <p>CycleStartDate and CycleEndDate are columns in a table called DataTime</p>
  
  <p>BillDate is a column in a table called BillingData</p>
  
  <p>This is the BillDate values:</p>
  
  <pre><code>2012-07-27 00:00:00.000
  2012-07-27 00:00:00.000
  2012-08-27 00:00:00.000
  2012-08-27 00:00:00.000
  2012-09-28 00:00:00.000
  2012-09-28 00:00:00.000
  2012-10-26 00:00:00.000
  2012-10-26 00:00:00.000
  2012-11-27 00:00:00.000
  2012-11-27 00:00:00.000
  2012-12-27 00:00:00.000
  </code></pre>
  
  <p>How would I set the CycleStartDate values based on the requirements?
  The tables Datetime and BillingData are connected by a column called MeterID.</p>