Symmetric Pairs

  • + 0 comments

    ngoccth_SQL SERVER: WITH table_1 AS ( SELECT F1.X As X, F1.Y as Y, COUNT(F1.X) as num FROM Functions AS F1 INNER JOIN Functions AS F2 ON F1.X = F2.Y AND F1.Y = F2.X AND F1.X <= F1.Y AND F2.X >= F2.Y GROUP BY F1.X, F1.Y ) SELECT X, Y from table_1 WHERE X != Y OR (X = Y AND num > 1) ORDER BY X