← Back to CTEs
Question 47
Took Both CS101 and MATH110
Took Both CS101 and MATH110
Define one CTE namedtakenthat lists every completed enrollment asstudent_idand the coursecode, then jointakentwice tostudents: once forCS101and once forMATH110. Returnfirst_nameandlast_nameof the students who completed both courses, sorted bylast_name, thenfirst_name.
Expected result:
+------------+-----------+ | first_name | last_name | +------------+-----------+ | Elijah | Costa | | Charlotte | Dubois | | Grace | Lee | | James | Mensah | | Ava | Patel | | Emily | Zhang | +------------+-----------+ 6 rows
Hints3 available
Sign in to use hintsTopics:
CTEs
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (sel, ins, desc)
Results
Run your SQL to see every statement's output here, then how it compares with the expected answer.
Not sure what is in a table? SHOW TABLES lists them and DESCRIBE students shows the columns — or open the database browser on the left.