Question 6 (Symmetric Pairs)

 avatar
user_6227789376
mysql
2 years ago
261 B
0
Indexable
Never
-- Medium
-- Question 6 (Symmetric Pairs):

SELECT f1.x AS X, f1.y AS Y

FROM   functions f1, functions f2

WHERE  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(X) > 1
ORDER  BY X ASC;