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.
i've not yet learnt cte can someone help with a basic sql code.
i wrote this but it incorrect
SELECT GROUP_CONCAT(num SEPARATOR '&') AS primes
FROM (
SELECT n.num
FROM numbers n
WHERE n.num <= 100
AND n.num > 1
AND NOT EXISTS (
SELECT 1
FROM numbers d
WHERE d.num > 1 AND d.num < n.num AND n.num % d.num = 0
)
) AS prime_list;
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Print Prime Numbers
You are viewing a single comment's thread. Return to all comments →
i've not yet learnt cte can someone help with a basic sql code. i wrote this but it incorrect
SELECT GROUP_CONCAT(num SEPARATOR '&') AS primes FROM ( SELECT n.num FROM numbers n WHERE n.num <= 100 AND n.num > 1 AND NOT EXISTS ( SELECT 1 FROM numbers d WHERE d.num > 1 AND d.num < n.num AND n.num % d.num = 0 ) ) AS prime_list;