1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| with match_recognized_data as
(select report_id,
measure_code,
pos_mdm,
current_value,
prev_mdm,
next_mdm,
prev_value,
next_value,
--class,
--mn,
diff_prev,
diff_next
from measure m
match_recognize(
partition by report_id
order by pos_mdm
measures value as current_value,
prev(first(pos_mdm)) prev_mdm,
next(final last(pos_mdm)) next_mdm,
nvl(prev(first(value)), 0) prev_value,
nvl(next(final last(value)), 0) next_value,
pos_mdm - prev(first(pos_mdm)) diff_prev,
next(final last(pos_mdm)) - pos_mdm diff_next,
classifier() AS class,
match_number() AS mn
all rows per match
pattern(PunchPosition+)
define PunchPosition as measure_code = 'PunchPosition_DevPosCDmm'
)
WHERE report_id = 481
)
select d.*,
current_value + case when nvl(diff_prev, diff_next) < nvl(diff_next, diff_prev) then prev_value else next_value end somme
from match_recognized_data d ; |
Partager