title: Excluding rows from sql operation when no entry exists for an earlier timestamp
body: <p>I would like to sum over rows but only include values for which there exists a timestamp five minutes ago. I am using bigquery, which doesn't appear to support a timestamp_diff operation (but a datediff).</p>
  
  <p>Consider the following data (mytable):</p>
  
  <pre><code>time (timestamp)    meter (int) value (float)
  2013-07-03 07:50:00  1           3
  2013-07-03 07:50:00  2           4
  2013-07-03 07:55:00  1           3
  2013-07-03 07:55:00  2           4
  2013-07-03 08:00:00  1           3
  2013-07-03 08:00:00  2           4
  2013-07-03 08:05:00  1           3
  2013-07-03 08:10:00  1           3
  2013-07-03 08:10:00  2           4
  </code></pre>
  
  <p>The query I would like to expand upon can first be defined as:</p>
  
  <pre><code>SELECT time, SUM(value) AS sumValue, COUNT(value) AS obs
  FROM mytable
  GROUP BY time
  </code></pre>
  
  <p>The output is then:</p>
  
  <pre><code>time                 sumValue  obs
  2013-07-03 07:50:00  7         2
  2013-07-03 07:55:00  7         2
  2013-07-03 08:00:00  7         2
  2013-07-03 08:05:00  3         1
  2013-07-03 08:10:00  7         2
  </code></pre>
  
  <p>I would like this query to be expanded so that meter 2's value is not included in sumValue for 2013-07-03 08:10:00 (so sumValue here = 3), because it did not have an entry for five minutes earlier. Another consequence of this is that sumValue for the first timestamp would be zero. The desired output would then be:</p>
  
  <pre><code>time                 sumValue  obs
  2013-07-03 07:50:00  0         0
  2013-07-03 07:55:00  7         2
  2013-07-03 08:00:00  7         2
  2013-07-03 08:05:00  3         1
  2013-07-03 08:10:00  3         1
  </code></pre>
  
  <p>Can this be done in bigquery?</p>