We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- SQL
- Advanced Join
- Symmetric Pairs
- Discussions
Symmetric Pairs
Symmetric Pairs
Sort by
recency
|
1569 Discussions
|
Please Login in order to post a comment
SELECT DISTINCT X1,Y1 FROM (Select F1.X X1,F1.Y Y1,F2.X X2,F2.Y Y2 from Functions F1 , Functions F2) WHERE X1=Y2 AND X2=Y1 AND X1<=Y1 ORDER BY 1 ;
select * from ((select distinct f1.X, f1.Y from functions f1 join functions f2 on f1.X = f2.Y and f1.Y = f2.X and f1.X < f1.Y ) union (select X, Y from functions where X=Y group by X,Y having count(*) > 1))t order by t.X
select X,Y from ( select X,Y,LEAD(Y) over() as Y2, LEAD(X) over() as X2,abs(X-Y) as diff from Functions order by diff,X ) as sub where X=Y2 and Y=X2 order by XSELECT f.X, f.Y FROM Functions AS f inner join Functions AS f1 on f.X=f1.Y AND f.Y=f1.X WHERE f.X <= f.Y GROUP by f.X,f.Y HAVING f.X < f.Y or (count(f1.x)>=2) ORDER BY f.X