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.
The first condition in that line makes sure pairs with the same X and Y values don't get to count themselves as their symmetric pair. (e.g. if 10 10 appears one time it's not counted as a symmetric pair, but as 13 13 appears twice, that is a symmetric pair)
The second condition ensures that only one of a pair is displayed. (e.g. if 3 24 and 24 3 form a symmetric pair, it will only display 3 24, not 24 3 as well.)
Symmetric Pairs
You are viewing a single comment's thread. Return to all comments →
Here's a simple solution that avoids using joins or subqueries:
The key is the HAVING line, with two conditions.
The first condition in that line makes sure pairs with the same X and Y values don't get to count themselves as their symmetric pair. (e.g. if 10 10 appears one time it's not counted as a symmetric pair, but as 13 13 appears twice, that is a symmetric pair)
The second condition ensures that only one of a pair is displayed. (e.g. if 3 24 and 24 3 form a symmetric pair, it will only display 3 24, not 24 3 as well.)