Closest class scores


Suppose you are given a table containing students and their corresponding test scores:

Table: class_scores

student_id name score
1 John 95
2 Christy 98
3 Rita 87
4 Gilberto 55
5 Perry 80
6 Darlene 72
7 Raquel 68
8 Chris 88

Using the table, write a SQL query to return the two students with the closest test scores (absolute value).

You can view/query these tables in an interactive SQL fiddle here.


Access restricted

Subscribe to premium account to see the solution.

Get premium now