sql - How to get change points in oracle select query? -


how can select change points data set

1   0 2   0 3   0 4   100 5   100 6   100 7   100 8   0 9   0 10  0 11  100 12  100 13  0 14  0 15  0 

i want result

4  7  100  11 12 100 

this query based on analytic functions lag() , lead() gives expected output:

select id, nid, point    (     select id, point, p1, lead(id) on (order id) nid        (         select id, point,             decode(lag(point) on (order id), point, 0, 1) p1,             decode(lead(point) on (order id), point, 0, 2) p2          test)      p1<>0 or p2<>0)  p1=1 , point<>0 

sqlfiddle


edit: may want change line 3 in case there 1 row changing point:

    ...     select id, point, p1,         case when p1=1 , p2=2 id else lead(id) on (order id) end nid      ... 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -