Instantly share code, notes, and snippets.

Embed
What would you like to do?
MISQUERY ONLINE
SELECT n
FROM (
(WITH RECURSIVE numbers (x) AS (
SELECT 2
UNION ALL
SELECT x + 1 FROM numbers WHERE x <= 10000)
SELECT tbl.n, COUNT(tbl.n)
FROM numbers AS n
INNER JOIN tbl
ON MOD(tbl.n, x) = 0
GROUP BY tbl.n)
) AS ans
WHERE ans.count = 1
ORDER BY ans.n;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment