Interview Query

Closest SAT Scores

38
Have you seen this question before?

Given a table of students and their SAT test scores, write a query to return the two students with the closest test scores with the score difference.

If there are multiple students with the same minimum score difference, select the student name combination that is higher in the alphabet. 

Example:

Input:

scores table

Column Type
id INTEGER
student VARCHAR
score INTEGER

Output:

Column Type
one_student VARCHAR
other_student VARCHAR
score_diff INTEGER
Next question: Integer String Addition
.....
MySQL 8.0.17
Loading editor
Use Shift + Enter to run query