Analytic functions may help you.
See http://download-uk.oracle.com/docs/c...nctions001.htm
Code:select store, ts, category, prev_category, next_category from ( select store, ts, category, lag(category,1,category) over(partition by store order by ts) as prev_category, lead(category,1,category) over(partition by store order by ts) as next_category from simple ) where category!=prev_category or category!=next_category




Reply With Quote