Find the names of the two highest scoring individuals in a table of data.

Write a SQL query to find the names of the two highest scoring individuals in a table of data.

Problem

Given a table of data with three columns - id, name, and score - write a SQL query to find the names of the two highest scoring individuals.
Example input:
id | name | score
1 | John | 10
2 | Jane | 9
3 | Joe | 8
4 | Jill | 7
Example output:
name
John
Jane

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
SELECT name
FROM table
ORDER BY score DESC
LIMIT 2;

/*

This solution is optimal because it uses the ORDER BY and LIMIT clauses to sort the table by score in descending order and then limit the results to the first two rows.

*/

A.I. Evaluation of the Solution

The candidate's solution is correct and demonstrates a good understanding of SQL.

Evaluated at: 2022-11-08 00:15:45

Community solutions:

Check these solutions from our community and artificial intelligence:
The candidate's solution is correct and demonstrates a good understanding of SQL.