SQL Subquery Exercises: Display all the information for those employees whose id is any id who earn the second highest salary
SQL SUBQUERY: Exercise-12 with Solution
Write a query to display all the information for those employees whose id is any id who earn the second highest salary.
Sample table: employees
SELECT * FROM employees WHERE employee_id IN (SELECT employee_id FROM employees WHERE salary = (SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees)));
employee_id first_name last_name email phone_number hire_date job_id salary commission_pct manager_id department_id 101 Neena Kochhar NKOCHHAR515.123.4568 2005-09-21 AD_VP 17000.00 0.00 100 90 102 Lex De Haan LDEHAAN 515.123.4569 2001-01-13 AD_VP 17000.00 0.00 100 90
Contribute your code and comments through Disqus.
Previous: Write a query to display all the information of the employees who does not work in those departments where some employees works whose manager id within the range 100 and 200.
Next: Write a query to display the employee name( first name and last name ) and hiredate for all employees in the same department as Clara. Exclude Clara.
What is the difficulty level of this exercise?