programming-examples/sql/SubqueriesHRDatabase/Write a query to display the employee id, name ( first name and last name ), salary, department.sql

13 lines
657 B
MySQL
Raw Normal View History

2019-11-18 14:05:53 +01:00
/*Write a query to display the employee id, name ( first name and last name ), salary, department name and city for all the
employees who gets the salary as the salary earn by the employee which is maximum within the joining person
January 1st, 2002 and December 31st, 2003.
*/
SELECT a.employee_id, a.first_name, a.last_name, a.salary, b.department_name, c.city
FROM employees a, departments b, locations c
WHERE a.salary =
(SELECT MAX(salary)
FROM employees
WHERE hire_date BETWEEN '01/01/2002' AND '12/31/2003')
AND a.department_id=b.department_id
AND b.location_id=c.location_id;