Given a table of employees, this query finds the employees who have been with the company for more than 10 years.
Given a table of employees, write a query to find the employees who have been with the company for more than 10 years. Example input: +----+------------+------------+ | id | first_name | last_name | +----+------------+------------+ | 1 | John | Doe | | 2 | Jane | Doe | | 3 | Joe | Smith | | 4 | Bill | Gates | | 5 | Karen | Johnson | +----+------------+------------+ Example output: +----+------------+------------+ | id | first_name | last_name | +----+------------+------------+ | 1 | John | Doe | | 2 | Jane | Doe | | 4 | Bill | Gates | +----+------------+------------+
SELECT * FROM employees WHERE DATEDIFF(CURDATE(), hire_date) > 3650; /* The above solution is optimal because it uses the DATEDIFF function to calculate the difference between the current date and the hire date. */
The candidate's solution is correct and uses an optimal approach to solving the problem.
Evaluated at: 2022-11-11 08:15:45