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.
Select sth.X,sth.Y
from
(
select f1.X as X, f1.Y AS Y --, f2.X as X2,f2.Y as Y2
from functions f1
CROSS JOIN functions f2
where
f1.X< f1.Y and
f1.X = f2.Y and f2.X = f1.Y
UNION
SELECT X, Y
from functions
where X = Y
group by X,Y
having count(*) > 1) sth
Order by sth.X,sth.Y
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Symmetric Pairs
You are viewing a single comment's thread. Return to all comments →
Select sth.X,sth.Y from ( select f1.X as X, f1.Y AS Y --, f2.X as X2,f2.Y as Y2 from functions f1 CROSS JOIN functions f2 where f1.X< f1.Y and f1.X = f2.Y and f2.X = f1.Y
UNION
SELECT X, Y from functions where X = Y group by X,Y having count(*) > 1) sth Order by sth.X,sth.Y