Search⌘ K
AI Features

Solution: Compute Student CGPA

Explore how to compute the cumulative GPA for students by joining student and semester data, applying aggregation functions, grouping results accurately, and sorting the output to highlight top performers using SQL.

We'll cover the following...

Query

SELECT
s.Name,
ROUND(AVG(se.SGPA), 2) AS CGPA
FROM students s
JOIN semesters se ON s.ID = se.StudentID
GROUP BY s.ID, s.Name
ORDER BY CGPA DESC;

Explanation

This query calculates the CGPA (Cumulative Grade Point Average) for each student by taking the average of all their ...