SQL> with c as
2 (select 10 as id, 21 as typ, 0 as period from dual
3 union all
4 select 10 as id, 22 as typ, 0 as period from dual
5 union all
6 select 10 as id, 23 as typ, 0 as period from dual
7 union all
8 select 10 as id, 21 as typ, 1 as period from dual
9 union all
10 select 10 as id, 21 as typ, 2 as period from dual
11 union all
12 select 10 as id, 21 as typ, 3 as period from dual
13 union all
14 select 10 as id, 21 as typ, 4 as period from dual
15 union all
16 select 10 as id, 22 as typ, 1 as period from dual
17 union all
18 select 10 as id, 22 as typ, 2 as period from dual
19 union all
20 select 10 as id, 22 as typ, 3 as period from dual
21 union all
22 select 10 as id, 22 as typ, 4 as period from dual
23 ),
24 spl as (
25 select 0 as code, 0 as gr from dual
26 union all
27 select 1 as code, 1 as gr from dual
28 union all
29 select 2 as code, 1 as gr from dual
30 union all
31 select 3 as code, 1 as gr from dual
32 union all
33 select 4 as code, 1 as gr from dual
34 union all
35 select 5 as code, 5 as gr from dual
36 union all
37 select 6 as code, 6 as gr from dual
38 )
39 select id, typ, gr, nvl2(ora_hash(t2.tmp), 'matched', 'not matched') sign
40 from (select id, typ, cast(collect(period) as sys.odcinumberlist) tmp
41 from c
42 group by id, typ) t1
43 left join (select gr, cast(collect(code) as sys.odcinumberlist) tmp
44 from spl
45 group by gr) t2
46 on ora_hash(t1.tmp) = ora_hash(t2.tmp);
ID TYP GR SIGN
---------- ---------- ---------- -----------
10 23 0 matched
10 22 not matched
10 21 not matched
|