← Back to CTEs
Question 46
How Full Each Course Is
How Full Each Course Is
Chain two CTEs.per_coursecounts the enrollments percourse_idwhosestatusis notdropped(columnenrolled);filljoins that tocoursesand addspct_full, the percentage ofmax_seatstaken, rounded to 1 place. Fromfill, returncode,enrolled,max_seatsandpct_full, sorted bypct_fulldescending, thencode.ART140has no enrollments and does not appear.
Expected result:
+---------+----------+-----------+----------+ | code | enrolled | max_seats | pct_full | +---------+----------+-----------+----------+ | CS230 | 11 | 35 | 31.4 | | ENG101 | 10 | 50 | 20 | | MATH110 | 14 | 80 | 17.5 | | BIO305 | 4 | 25 | 16 | | CS101 | 9 | 60 | 15 | | CS201 | 6 | 40 | 15 | | CS310 | 4 | 30 | 13.3 | | ENG250 | 4 | 30 | 13.3 | | MATH220 | 6 | 45 | 13.3 | | BUS150 | 9 | 90 | 10 | +---------+----------+-----------+----------+ (showing 10 of 13 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.