Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Searching for the Top Math Students Challenge | Grouping
Intermediate SQL
course content

Course Content

Intermediate SQL

Intermediate SQL

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

Searching for the Top Math Students Challenge

The school is pleased with our work and agrees to continue the collaboration.

Now they have a new task for us. The top 10 students with the highest average grades will be offered a trip to a scientific center as a reward. One mandatory condition is receiving a grade above 90 on the math exam. To find such students, they have turned to you.

Let's see what we need to do using our employee table as an example.

Suppose we need to find out in which departments there are employees who were hired before 2019 and the average salary in those departments. To implement such a task, we can use the following query:

1234
SELECT department, AVG(salary) AS average_salary FROM employees WHERE hire_date < '2019-01-01' GROUP BY department
copy

As you can see, there are only 3 such employees, and we used the necessary tools to achieve this result. Your task will be very similar, I'm sure you can handle it!

Here is the preview of a student_grades table we are working with:

Task

Your task is to retrieve up to 10 students with the highest average grade among all students who scored above or equal to 90 on the math exam.

Also, sort the result by the average_grade column in the descending order.

Give an alias average_grade to the average grade to ensure the task is successfully checked for correctness.

Task

Your task is to retrieve up to 10 students with the highest average grade among all students who scored above or equal to 90 on the math exam.

Also, sort the result by the average_grade column in the descending order.

Give an alias average_grade to the average grade to ensure the task is successfully checked for correctness.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 1. Chapter 5
toggle bottom row

Searching for the Top Math Students Challenge

The school is pleased with our work and agrees to continue the collaboration.

Now they have a new task for us. The top 10 students with the highest average grades will be offered a trip to a scientific center as a reward. One mandatory condition is receiving a grade above 90 on the math exam. To find such students, they have turned to you.

Let's see what we need to do using our employee table as an example.

Suppose we need to find out in which departments there are employees who were hired before 2019 and the average salary in those departments. To implement such a task, we can use the following query:

1234
SELECT department, AVG(salary) AS average_salary FROM employees WHERE hire_date < '2019-01-01' GROUP BY department
copy

As you can see, there are only 3 such employees, and we used the necessary tools to achieve this result. Your task will be very similar, I'm sure you can handle it!

Here is the preview of a student_grades table we are working with:

Task

Your task is to retrieve up to 10 students with the highest average grade among all students who scored above or equal to 90 on the math exam.

Also, sort the result by the average_grade column in the descending order.

Give an alias average_grade to the average grade to ensure the task is successfully checked for correctness.

Task

Your task is to retrieve up to 10 students with the highest average grade among all students who scored above or equal to 90 on the math exam.

Also, sort the result by the average_grade column in the descending order.

Give an alias average_grade to the average grade to ensure the task is successfully checked for correctness.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 1. Chapter 5
toggle bottom row

Searching for the Top Math Students Challenge

The school is pleased with our work and agrees to continue the collaboration.

Now they have a new task for us. The top 10 students with the highest average grades will be offered a trip to a scientific center as a reward. One mandatory condition is receiving a grade above 90 on the math exam. To find such students, they have turned to you.

Let's see what we need to do using our employee table as an example.

Suppose we need to find out in which departments there are employees who were hired before 2019 and the average salary in those departments. To implement such a task, we can use the following query:

1234
SELECT department, AVG(salary) AS average_salary FROM employees WHERE hire_date < '2019-01-01' GROUP BY department
copy

As you can see, there are only 3 such employees, and we used the necessary tools to achieve this result. Your task will be very similar, I'm sure you can handle it!

Here is the preview of a student_grades table we are working with:

Task

Your task is to retrieve up to 10 students with the highest average grade among all students who scored above or equal to 90 on the math exam.

Also, sort the result by the average_grade column in the descending order.

Give an alias average_grade to the average grade to ensure the task is successfully checked for correctness.

Task

Your task is to retrieve up to 10 students with the highest average grade among all students who scored above or equal to 90 on the math exam.

Also, sort the result by the average_grade column in the descending order.

Give an alias average_grade to the average grade to ensure the task is successfully checked for correctness.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

The school is pleased with our work and agrees to continue the collaboration.

Now they have a new task for us. The top 10 students with the highest average grades will be offered a trip to a scientific center as a reward. One mandatory condition is receiving a grade above 90 on the math exam. To find such students, they have turned to you.

Let's see what we need to do using our employee table as an example.

Suppose we need to find out in which departments there are employees who were hired before 2019 and the average salary in those departments. To implement such a task, we can use the following query:

1234
SELECT department, AVG(salary) AS average_salary FROM employees WHERE hire_date < '2019-01-01' GROUP BY department
copy

As you can see, there are only 3 such employees, and we used the necessary tools to achieve this result. Your task will be very similar, I'm sure you can handle it!

Here is the preview of a student_grades table we are working with:

Task

Your task is to retrieve up to 10 students with the highest average grade among all students who scored above or equal to 90 on the math exam.

Also, sort the result by the average_grade column in the descending order.

Give an alias average_grade to the average grade to ensure the task is successfully checked for correctness.

Switch to desktop for real-world practiceContinue from where you are using one of the options below
Section 1. Chapter 5
Switch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt