SQL Subquery Exercises: Display the employee id, 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
SQL SUBQUERY: Exercise-34 with Solution
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.
Sample table: employees
Sample table: departments
Sample table: locations
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;
employee_id first_name last_name salary department_name city 100 Steven King 24000.00 Executive Seattle
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a query to get the details of employees who manage a department.
Next: Write a query in SQL to display the department code and name for all departments which located in the city London.
What is the difficulty level of this exercise?