Created
April 25, 2022 01:06
-
-
Save fulmicoton/0966649e893adf6c607ac119d9c0c15b 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
WITH | |
poss AS ( | |
SELECT x, y, x*y AS p, x+y as s | |
FROM | |
GENERATE_SERIES(2,100) as x, | |
GENERATE_SERIES(2,100) as y | |
WHERE x + y <= 100 AND y > x | |
), | |
poss_after_sue_2 AS ( | |
SELECT * | |
FROM poss | |
WHERE poss.s NOT IN ( | |
SELECT poss.s | |
FROM poss | |
WHERE poss.p IN ( | |
SELECT p | |
FROM poss | |
GROUP BY p | |
HAVING COUNT(*) = 1 | |
) | |
) | |
), | |
poss_after_pete3 AS ( | |
SELECT * | |
FROM poss_after_sue_2 | |
WHERE p IN ( | |
SELECT p | |
FROM poss_after_sue_2 | |
GROUP BY p | |
HAVING COUNT(*) = 1 | |
) | |
) | |
SELECT x, y | |
FROM poss_after_pete3 | |
WHERE s in ( | |
SELECT s | |
FROM poss_after_pete3 | |
GROUP BY s | |
HAVING COUNT(*) = 1 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment