oracle - SQL - find rows that have the same set of values in a column -


i have table , want select rows have same set of values appear in column , return them pair of column.

for example, let's have table named table:

c1  c2   1   1   1   2   1   3   2   1   3   1   3   2   3   3   4   1   4   2   

when run query, should return row:

1  3 

because these 2 values in c1 have same set of values in column c2 (1,2,3).

i have incorrect query below returns rows have @ least 1 matching value in c2 , can't figure out how correct it.

select distinct t1.c1, t2.c1 table t1, table t2 t1.c1 != t2.c1  , t1.c2 = t2.c2 , t1.c1 < t2.c1 group s1.suppid, s2.suppid;   

any appreciated, thanks.

as not specify, 1 handle case of 2 sets of matching c2 values, outputting 2 rows - 1 each matched set.

with thetable (     select   1 c1,  1 c2 dual union  select   1 c1,   2   c2 dual union select   1 c1,   3   c2 dual union select   2 c1,   1   c2 dual union select   3 c1,   1   c2 dual union select   3 c1,   2   c2 dual union select   3 c1,   3   c2 dual union select   4 c1,   1   c2 dual union select   4 c1,   2  c2 dual union -- added fourrows give second set of matches select   5 c1,   1   c2 dual union select   5 c1,   2  c2 dual union select   6 c1,   1  c2 dual union select   6 c1,   2  c2 dual ) select list_c2, list_c1 (     select list_c2           ,listagg(c1,',') within group (order c1) list_c1     (                   select c1, listagg(c2,',') within group (order c2) list_c2              thetable             group c1          )     group list_c2             ) -- bring had more 1 c1 instr(list_c1,',') != 0 

showing following 2 sets of c2 values , matching lists of c1s

list_c2  list_c1 "1,2"    "4,5,6" "1,2,3"  "1,3" 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -