hana - Using SQL to get the continuous range of table -


here table named track , have 3 columns: time, speed, isoverspeed, below

time      speed isoverspeed 10:00:01    76      1 10:00:11    58      0 10:00:21    70      1 10:00:31    70      1 10:00:41    90      1 10:00:51    40      0 10:01:01    30      0 10:01:11    80      1 10:01:21    20      0 

what want calculate how many times , how long car overspeed, requirement continuous overspeed records count 1 time, in example, there 3 times overspeed not 4. thinking using window function seems not work. has idea? ps. result should 3 times, 50 seconds.

i think need this:

select     count(*) cnt, sum(seconds_between(dt.prevtime, dt.time)) sometime (     select t1.time, max(t2.time) prevtime     atable t1         join         atable t2 on t1.time > t2.time      t1.isoverspeed = 1     group t1.time) dt 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -