Created
April 23, 2015 03:12
-
-
Save doryokujin/fc0cf454f3aa45ccd4e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT n1.id, n2.id, n1.id || ' ♥ ' || n2.id | |
FROM | |
( | |
SELECT id, gender | |
FROM men_and_women | |
) n1 | |
JOIN | |
( | |
SELECT id, gender | |
FROM men_and_women | |
) n2 | |
ON n1.gender != n2.gender | |
HAVING n1.id < n2.id | |
ORDER BY n1.id, n2.id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment