LeetHack
← Problems

Top Scorers in the Class

You are given a table Students that holds data about students in a class, including their student_id, name, grade, and subject.

Write an SQL query to find all students who scored 85 or more in any subject. The result should contain the student_id, name, grade, and subject of these students, sorted by grade in descending order.

Return the results in the following format:

student_id name grade subject
2 Alice Johnson 92 Mathematics
4 John Doe 89 Science
... ... ... ...

Table Schema

Students

Column Type Description
student_id INT Unique ID for each student.
name VARCHAR(50) Name of the student.
grade INT Grade scored by the student in a subject.
subject VARCHAR(50) The subject the grade corresponds to.

Example Input Data

Sample Data in Students Table

student_id name grade subject
1 Michael Brown 78 Mathematics
2 Alice Johnson 92 Mathematics
3 Emily Davis 83 Science
4 John Doe 89 Science
5 Sarah Lee 95 History
6 Chris Evans 90 History
7 Olivia Smith 88 Mathematics
8 Jack Wilson 79 Science
9 Emma Thompson 85 History
10 Daniel King 91 Science

Loading...