Last active
December 27, 2015 13:59
-
-
Save jatorre/7336704 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH summary_groups as( | |
WITH summary as ( | |
select (row_number() over (order by time asc nulls last)+1)/2 as rownum,time | |
from sensor_log_2013_10_27_12_01 | |
order by time asc) | |
SELECT | |
max(time) OVER(PARTITION BY rownum) - | |
min(time) OVER(PARTITION BY rownum) diff | |
FROM summary) | |
SELECT | |
avg(diff) as diffavg, | |
(SELECT max(time)-min(time) as total_diff FROM sensor_log_2013_10_27_12_01 as subq)/avg(diff) as num_steps | |
FROM summary_groups | |
WHERE diff>0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment