Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Credit-Weighted GPA

GPA = sum(grade_points x credits) / sum(credits), rounded to 2 decimals. Return name and GPA, ordered by GPA descending.

Table schema

Students(id INT PRIMARY KEY, name VARCHAR(10))
Courses(id INT PRIMARY KEY, title VARCHAR(10), credits INT)
Enrollments(student_id INT, course_id INT, grade_points INT)

Sample data

Students
id | name
1 | Ann
2 | Bob
3 | Cy

Courses
id | title | credits
10 | Math | 4
20 | Physics | 3
30 | Art | 2

Enrollments
student_id | course_id | grade_points
1 | 10 | 4
1 | 20 | 3
1 | 30 | 4
2 | 10 | 2
2 | 20 | 3
3 | 10 | 3

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.