For example, starting with a table like this:
create table t as
select 'A' as x, level as y from dual connect by level<=5
union all
select 'B' as x, level+2 as y from dual connect by level<=5
union all
select 'C' as x, level as y from dual connect by level<=3
union all
select 'D' as x, level+2 as y from dual connect by level<=3;
alter table t add primary key (x, y);
select * from t;
X Y
- -
A 1
A 2
A 3
A 4
A 5
B 3
B 4
B 5
B 6
B 7
C 1
C 2
C 3
D 3
D 4
D 5
How do I get this:
SUBSET_X SUPERSET_X
-------- ----------
D A
C A
D B
I'm posting my own effort as an answer but wondering if there is some other fancy way, perhaps with analytics or a set operator I don't know about
--edit
My test data unintentionally implies that the sets always consist of consecutive integers - unfortunately this is not true with my real data.
