Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Average Student's Grade Challenge | Grouping
Intermediate SQL
course content

Contenuti del Corso

Intermediate SQL

Intermediate SQL

1. Grouping
2. Nested Subqueries
3. Joining Tables
4. DDL and DML in SQL

book
Average Student's Grade Challenge

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:

123
SELECT class_letter, COUNT(DISTINCT student_surname) AS anumber_of_students FROM student_grades GROUP BY class_letter
copy
Compito

Swipe to start coding

Your task now is to 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_surname column and the average of the grade column using the AVG function.
  • Add the alias average_grade to the second column.
  • Group the data by student_surname.
  • Sort the results by student_surname in ascending order.

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 1. Capitolo 4
toggle bottom row

book
Average Student's Grade Challenge

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:

123
SELECT class_letter, COUNT(DISTINCT student_surname) AS anumber_of_students FROM student_grades GROUP BY class_letter
copy
Compito

Swipe to start coding

Your task now is to 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_surname column and the average of the grade column using the AVG function.
  • Add the alias average_grade to the second column.
  • Group the data by student_surname.
  • Sort the results by student_surname in ascending order.

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 1. Capitolo 4
Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Siamo spiacenti che qualcosa sia andato storto. Cosa è successo?
some-alt