title: SQL how to convert row with date range to many rows with each date
body: <p>If I have a table that looks like this</p>
  
  <pre><code>begin date      end date        data
   2013-01-01     2013-01-04       7
   2013-01-05     2013-01-06       9
  </code></pre>
  
  <p>How can I make it be returned like this...</p>
  
  <pre><code>    date         data
   2013-01-01       7
   2013-01-02       7
   2013-01-03       7
   2013-01-04       7
   2013-01-05       9
   2013-01-06       9
  </code></pre>
  
  <p>One thing I was thinking of doing is to have another table that just has all the dates and then join the table with just dates to the above table using <code>date&gt;=begin date</code> and <code>date&lt;=end date</code> but that seems a little clunky to have to maintain that extra table with nothing but repetitive dates.  </p>
  
  <p>In some instances I don't have a data range but just an <code>as of</code> date which basically looks like my first example but with no <code>end date</code>.  The <code>end date</code> is implied by the next row's 'as of' date (ie end date should be the next row's <code>as of</code> -1).  I had a "solution" for this that uses the row_number() function to get the next value but I suspect that methodology, which the way I'm doing it has a bunch of nested self joins, contributes to very long query times.  </p>