The Year-Round Students
Retention is the number Fairhaven University is judged on, and the students who matter most to it are the ones who came back: still enrolled in a later term rather than drifting away after their first. The retention team wants those students identified so it can ask them what kept them here.
A student who took four courses in a single term has not come back — that is one term, however busy. What counts is turning up in more than one of the terms on record. The team works from student numbers at this stage, not names.
enrollments — one row per sitting: one student taking one course in one term. student_id points at a row in students and course_id at a row in courses. grade is the mark for that sitting, on the same 0-4 scale, and is NULL when no mark has been entered yet. semester is the term the sitting belongs to.
| student_id | course_id | grade | semester |
|---|---|---|---|
| 1 | 1 | 3.7 | Fall2023 |
| 1 | 2 | 3.9 | Spring2024 |
| 2 | 1 | 3.2 | Fall2023 |
| 2 | 3 | 3.5 | Fall2023 |
| 3 | 2 | 4.0 | Spring2024 |
| 3 | 4 | 3.8 | Spring2024 |
| 4 | 3 | 2.9 | Fall2023 |
| 5 | 1 | 3.6 | Fall2023 |
| 5 | 2 | NULL | Spring2024 |
The table already exists in the database — there is nothing to create or load.
Task: Write a query that returns a single column, student_id, listing every student whose sittings span more than one term, smallest student_id first.
Example output
If two students turned out to span more than one term, you would get a two-row answer like this — invented ids:
| student_id |
|---|
| 12 |
| 31 |
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in