Return the name and salary of the highest paid employee from a table of data.

Write a stored procedure that returns the name and salary of the highest paid employee from a table of data.

Problem

Given a table of data with employee id, name, and salary, write a stored procedure that returns the name and salary of the highest paid employee.
Input:
Table:
+--------+----------+--------+
| emp_id | emp_name | salary |
+--------+----------+--------+
| 1      | John     | 10000  |
| 2      | Jane     | 12000  |
| 3      | Joe      | 11000  |
+--------+----------+--------+
Output:
+----------+--------+
| emp_name | salary |
+----------+--------+
| Jane     | 12000  |
+----------+--------+

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
SELECT emp_name, salary
FROM employee
WHERE salary = (SELECT MAX(salary) FROM employee)

/*

The solution above is optimal because it uses a subquery to find the maximum salary and then returns the name and salary of the employee with that salary.

*/

A.I. Evaluation of the Solution

The candidate's solution is correct and demonstrates a good understanding of how to solve the problem. The approach is efficient and uses a subquery to find the maximum salary, which is then used to return the name and salary of the employee with that salary.

Evaluated at: 2022-11-22 08:16:06