🙏 We need your help! SQLtest.online has no ads and lives only on donations. Even a small amount helps. Donate now →
SQL code copied to buffer
Task 2:

Departments Above the University GPA

MariaDB
Find the departments whose students do better than the university as a whole. In a CTE, compute for every department_id of the students table the number of students and their average gpa rounded to 3 decimal places. Then keep the departments whose average is above the average gpa of all students and add the department name from departments.
Output the columns name, students and avg_gpa, sorted by avg_gpa from the highest.
Expected result Columns: 3 · Rows: 8
name students avg_gpa

Sample rows open after wrong checks: 0 of 2

Write your query below and click "Check it!". Tables are described in the right pane.

Tutorial

By checking a query, you agree that it is stored without your account details and may be included in anonymized datasets, including for AI training. Learn more

The query result will appear here. Ctrl+Enter - Run query