Q: You are working on a database that stores information about employees and departments. Write a query that will return the names and department names of all employees who have been with the company for more than 5 years.
SELECT e.name, d.name
FROM employees e
JOIN departments d
ON e.department_id = d.id
WHERE DATEDIFF(YEAR, e.hire_date, CURDATE()) > 5;