Challenge: Average Student's Grade
You've done an excellent job and helped the construction company. They have started working on expanding the Yellow metro line.
They have recommended you, and the school has shown interest in you because they also have several tasks for you. But first, let's familiarize ourselves with the student_grades table they provide:
The table contains grades for exams in various subjects.
The school has a total of 100 students, information about whom is provided in the given table. There is information in the class_letter column, which has 3 options: A, B, or C. The subject name(subject_name), as well as the student's grade(grade), are included.
Let's see how many students there are in each class with the following query:
123SELECT class_letter, COUNT(DISTINCT student_surname) AS anumber_of_students FROM student_grades GROUP BY class_letter
Swipe to start coding
Calculate the average grade for all subjects for each student. Also, for the convenience of the teachers, you need to sort the students' last names in alphabetical order. Use aggregation with the AVG() function and give an alias average_grade to ensure successful testing.
Brief Instructions
- Retrieve the
student_surnamecolumn and the average of thegradecolumn using theAVGfunction. - Add the alias
average_gradeto the second column. - Group the data by
student_surname. - Sort the results by
student_surnamein ascending order.
Solution
Thanks for your feedback!
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Can you explain what the SQL query does?
What are the results of this query?
How can I analyze grades by subject instead of class?
Awesome!
Completion rate improved to 4
Challenge: Average Student's Grade
Swipe to show menu
You've done an excellent job and helped the construction company. They have started working on expanding the Yellow metro line.
They have recommended you, and the school has shown interest in you because they also have several tasks for you. But first, let's familiarize ourselves with the student_grades table they provide:
The table contains grades for exams in various subjects.
The school has a total of 100 students, information about whom is provided in the given table. There is information in the class_letter column, which has 3 options: A, B, or C. The subject name(subject_name), as well as the student's grade(grade), are included.
Let's see how many students there are in each class with the following query:
123SELECT class_letter, COUNT(DISTINCT student_surname) AS anumber_of_students FROM student_grades GROUP BY class_letter
Swipe to start coding
Calculate the average grade for all subjects for each student. Also, for the convenience of the teachers, you need to sort the students' last names in alphabetical order. Use aggregation with the AVG() function and give an alias average_grade to ensure successful testing.
Brief Instructions
- Retrieve the
student_surnamecolumn and the average of thegradecolumn using theAVGfunction. - Add the alias
average_gradeto the second column. - Group the data by
student_surname. - Sort the results by
student_surnamein ascending order.
Solution
Thanks for your feedback!
single