Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Several Aggregate Functions in the Query | Grouping
Intermediate SQL
course content

Kurssisisältö

Intermediate SQL

Intermediate SQL

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

book
Several Aggregate Functions in the Query

The school now knows the last names of those students who received more than one grade for exams, and the administration has decided to calculate the average grade from multiple grades of these students, and that will be their final grade.

Tehtävä

Swipe to start coding

You should retrieve the last names of students with more than one exam grade and also calculate the average grade from all their grades. In the response, you should have 2 columns: the first one is the student_surname, and the second one is the average_grade. Use AVG() and COUNT() aggregate functions in this task.

Also, sort the result by the student_surname column in the ascending order.

Brief Instructions

  • Retrieve the student_surname column and the average of the grade column using the AVG function.
  • Assign the alias average_grade to the second column.
  • Group the data by student_surname.
  • Use the HAVING clause to filter the results based on COUNT(grade) > 1.
  • Sort the results by student_surname.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 7
toggle bottom row

book
Several Aggregate Functions in the Query

The school now knows the last names of those students who received more than one grade for exams, and the administration has decided to calculate the average grade from multiple grades of these students, and that will be their final grade.

Tehtävä

Swipe to start coding

You should retrieve the last names of students with more than one exam grade and also calculate the average grade from all their grades. In the response, you should have 2 columns: the first one is the student_surname, and the second one is the average_grade. Use AVG() and COUNT() aggregate functions in this task.

Also, sort the result by the student_surname column in the ascending order.

Brief Instructions

  • Retrieve the student_surname column and the average of the grade column using the AVG function.
  • Assign the alias average_grade to the second column.
  • Group the data by student_surname.
  • Use the HAVING clause to filter the results based on COUNT(grade) > 1.
  • Sort the results by student_surname.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 7
Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Pahoittelemme, että jotain meni pieleen. Mitä tapahtui?
some-alt