Consider the following time series data
10-5-8-20-30-15-20-2-14-6-50-20-30-60-25-15-0-4-2-8-10-15-12-40-20
These are the values of y, and the x column starts from 1 respectively.
CREATE TABLE "Z_AXIS" (X NUMBER, Y NUMBER)
I have come to the conclusion that if the data in the y-column are compared three by three, the maximum value in each triad, is the peak point.
Does anyone have an idea how to specify peak points without using cursor, loop, lead and lag?
Advertisement
Answer
If you mean that a given y
value is larger than the y
values on the previous or next row and your x
values are really sequential with no gaps (as your question specifies), then you just want a join
:
select z.* from z_axis z join z_axis z_prev on z_prev.x = z.x - 1 join z_axis z_next on z_next.x = z.x + 1 where z.y > z_prev.y and z.y > z_next.y;