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 | Section
Intermediate SQL
セクション 1.  5
single

single

bookSearching 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.

タスク

スワイプしてコーディングを開始

Retrieve up to 10 students who have scored at least 90 in at least one mathematics exam. For those students, calculate the average of their grades in Mathematics only. Sort the results by this average (alias it as average_grade) in descending order.

Brief Instructions

  • Select student_surname and the average of the grade column using the AVG() function.
  • Assign the alias average_grade to the second column.
  • First, determine which students have at least one mathematics grade ≥ 90.
  • Include only Mathematics grades when calculating the average.
  • Group the results by student_surname.
  • Sort the results by average_grade in descending order.
  • Use LIMIT 10 to return only 10 results.

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  5
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt