3.27
Using the university schema, write an SQL query to find the IDs of those students who have retaken at least three distinct courses at least once (i.e, the student has taken the course at least two times).
WITH retakers(id,course_id,frequency) AS (
SELECT id,course_id,COUNT(*)
FROM takes
GROUP BY id,course_id
HAVING COUNT(*) > 1
)SELECT id
FROM retakers
GROUP BY id
HAVING COUNT(*) >= 3;