title: Do loop in BigQuery
body: <p>I have a table that looks like this in BigQuery:</p>
  
  <pre><code>Type    Start_Date  End_Date   Total_Spend
  TV      20180101   20180131    10000
  Radio   20180107   20180207    5000
  </code></pre>
  
  <p>And I want to run a query that runs a loop that creates a table that splits each row into a daily table:</p>
  
  <pre><code>Type     Date      Spend
  TV       20180101   322,6
  TV       20180102   322,6
  TV       20180103   322,6
  TV       20180104   322,6
  TV       20180105   322,6
  TV       20180106   322,6
  TV       20180107   322,6
  ...
  TV       20180131   322,6
  Radio    20180107   161,3
  Radio    20180108   161,3
  Radio    20180109   161,3
  ...
  Radio    20180207   161,3
  </code></pre>
  
  <p>Basically the do loop I want to create is like this:</p>
  
  <pre><code>do date=start_date to end_date;
      spend = total_spend/(end_date-start_date+1);
  </code></pre>
  
  <p>But I do not know how to do so in BigQuery. Any ideas or suggestions?</p>