Symmetric Pairs

Sort by

recency

|

1468 Discussions

|

  • + 0 comments

    select concat(f1.x," ",f1.y) from functions f1 join functions f2 on concat(f1.x," ",f1.y)=concat(f2.y," ",f2.x) group by f1.x,f1.y having case when f1.x=f1.y and count(concat(f1.x," ",f1.y))>1 then 1 when f1.x!=f1.y then 1 else 2 end = 1 and f1.x<=f1.y order by f1.x asc

  • + 0 comments

    ` select distinct results.XX, results.YY from ( select F1.ID1, F2.ID2, F1.X as XX, F1.Y as YY, F2.X, F2.Y from (select @rownum1 := @rownum1 + 1 as ID1, F.X, F.Y from (SELECT @rownum1 := 0) as r, Functions as F) as F1, (select @rownum2 := @rownum2 + 1 as ID2, F.X, F.Y from (SELECT @rownum2 := 0) as r, Functions as F) as F2 where F1.ID1 != F2.ID2 and F1.X = F2.Y and F1.Y = F2.X ) as results where results.XX <= results.YY order by results.XX;

    `

  • + 0 comments

    select a.x, a.y from functions a join functions b on a.y=b.x and a.x=b.y group by a.x, a.y having (count(*)>1 and a.x=a.y) or a.x

  • + 0 comments

    SELECT distinct F1.X, F1.Y from Functions F1 join Functions F2 on F1.X = F2.Y and F1.Y = F2.X Where F1.X < F1.Y union all ( select distinct X, Y from Functions where X=Y group by X,Y having Count(*)>1 ) order by F1.X

  • + 0 comments

    WITH functions_row_n AS( SELECT x, y, ROW_NUMBER() OVER(ORDER BY x, y) row_n FROM functions)

    SELECT DISTINCT a.x, a.y FROM functions_row_n a, functions_row_n b WHERE a.row_n <> b.row_n AND a.x = b.y AND a.y = b.x AND a.x <= a.y;