Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Question on Match_recognize

Ben SPJul 3 2017 — edited Jul 3 2017

Hello all,

I am trying to study Match_recognize feature in 12c and i have a question related to this.

below are the create table and insert scrips.

create table tttd (dt date,val number)

/

INSERT INTO tttd

VALUES(TO_DATE('2017-07-02 10:42:33', 'YYYY-MM-DD HH24:MI:SS'),25);

INSERT INTO tttd

VALUES(TO_DATE('2017-07-01 10:42:33', 'YYYY-MM-DD HH24:MI:SS'),20);

INSERT INTO tttd

VALUES(TO_DATE('2017-06-30 10:42:33', 'YYYY-MM-DD HH24:MI:SS'),50);

INSERT INTO tttd

VALUES(TO_DATE('2017-06-29 10:42:33', 'YYYY-MM-DD HH24:MI:SS'),40);

INSERT INTO tttd

VALUES(TO_DATE('2017-06-28 10:42:33', 'YYYY-MM-DD HH24:MI:SS'),90);

INSERT INTO tttd

VALUES(TO_DATE('2017-06-27 10:42:33', 'YYYY-MM-DD HH24:MI:SS'),80);

INSERT INTO tttd

VALUES(TO_DATE('2017-06-26 10:42:33', 'YYYY-MM-DD HH24:MI:SS'),70);

INSERT INTO tttd

VALUES(TO_DATE('2017-06-25 10:42:33', 'YYYY-MM-DD HH24:MI:SS'),110);

INSERT INTO tttd

VALUES(TO_DATE('2017-06-24 10:42:33', 'YYYY-MM-DD HH24:MI:SS'),90);

INSERT INTO tttd

VALUES(TO_DATE('2017-06-23 10:42:33', 'YYYY-MM-DD HH24:MI:SS'),100);

-----

I have copied both sql and output. my question is why A_Val is null for alternative rows and why V_VAL is same for each 2 rows.( Basically i am trying to understand how this query is working).

select * from tttd

match_recognize (

order by dt

measures

a.val a_val,

b.val b_val

all rows per match

pattern (b a)

define

a as 1=1

)

pastedImage_0.png

Thanks.

This post has been answered by mathguy on Jul 3 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 31 2017
Added on Jul 3 2017
11 comments
433 views