Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

sql select students closest in score

SELECT 
    s1.student AS one_student
    , s2.student AS other_student
    , ABS(s1.score - s2.score) AS score_diff
FROM scores AS s1
INNER JOIN scores AS s2
    ON s1.id != s2.id
        AND s1.id < s2.id
ORDER BY 3 ASC, 1 ASC
LIMIT 1
Source by www.interviewquery.com #
 
PREVIOUS NEXT
Tagged: #sql #select #students #closest #score
ADD COMMENT
Topic
Name
1+4 =