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

#### |

#### 1427 Discussions

#### |

Please Login in order to post a comment

MS SQL SERVER`with ranked_f as( select row_number() over(order by x) as id, x, y from functions ) select f1.x, f1.y from ranked_f f1 left join ranked_f f2 on f1.x = f2.y and f1.y = f2.x and f1.id

with FunctionsV2 as (select X,Y from Functions union all select Y as X,X as Y from Functions) select X,Y from (select X,Y, count(*) as countPairs from FunctionsV2 group by X,Y ) as PairsTable where (countPairs =2 and X

SELECT F1.x AS X, F1.y AS Y FROM Functions F1 JOIN Functions F2 ON F1.x = F2.y AND F1.y = F2.x WHERE F1.x <= F1.y ORDER BY F1.x;

what's the problem in my code? please help me