You're working as a data analyst for a university's academic excellence program. The program wants to identify outstanding students who have not only completed all required courses in their major but have also achieved perfect grades (A) in every single one of them.
Given three database tables:
students- Contains student information including their majorcourses- Contains course information organized by majorenrollments- Contains enrollment records with grades
Your task: Write a SQL query to find students who have taken all courses offered in their major and received an 'A' grade in every course.
This is a classic "division" problem in relational algebra - finding entities that are related to all entities in another set. Think of it as finding students who have a perfect academic record in their field of study.
Return the results ordered by student_id in ascending order.
Input & Output
Constraints
- 1 โค student_id โค 1000
- 1 โค course_id โค 1000
- Student names and course names are non-empty strings
- Major names are consistent across tables
- Grades are single uppercase letters (A, B, C, D, F)
- Each student has exactly one major
- Each course belongs to exactly one major