Skip to content

Instantly share code, notes, and snippets.

@jatorre jatorre/gist:7336704
Last active Dec 27, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.