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 DISTINCT f1.x AS x1, f1.y AS y1
FROM functions f1
JOIN functions f2
ON f1.x = f2.y AND f1.y = f2.x
WHERE f1.x <= f1.y
group by f1.x,f1.y
having (count(x1)>1 and f1.x=f1.y) or (f1.x<>f1.y)
ORDER BY f1.x
i tried this
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 DISTINCT f1.x AS x1, f1.y AS y1 FROM functions f1 JOIN functions f2 ON f1.x = f2.y AND f1.y = f2.x WHERE f1.x <= f1.y group by f1.x,f1.y having (count(x1)>1 and f1.x=f1.y) or (f1.x<>f1.y) ORDER BY f1.x
i tried this