SQL Subquery Exercises: Display the employee name, employee id and salary of all employees who report to Payam
SQL SUBQUERY: Exercise-5 with Solution
From the following table, write a SQL query to find those employees who report to that manager whose first name is ‘Payam’. Return first name, last name, employee ID and salary.
Sample table: employees
SELECT first_name, last_name, employee_id, salary FROM employees WHERE manager_id = (SELECT employee_id FROM employees WHERE first_name = 'Payam' );
first_name last_name employee_id salary Jason Mallin 133 3300.00 Michael Rogers 134 2900.00 Ki Gee 135 2400.00 Hazel Philtanker 136 2200.00 Kelly Chung 188 3800.00 Jennifer Dilly 189 3600.00 Timothy Gates 190 2900.00 Randall Perkins 191 2500.00
Contribute your code and comments through Disqus.
Previous: From the following table, write a SQL query to find those employees who earn more than the average salary. Return employee ID, first name, last name.
Next: From the following tables, write a SQL query to find all those employees who work in the Finance department. Return department ID, name (first), job ID and department name.
Test your Programming skills with w3resource's quiz.
What is the difficulty level of this exercise?
SQL: Tips of the Day
"where 1=1" statement?
It's usually when folks build up SQL statements.
When you add and value = "Toyota" you don't have to worry about whether there is a condition before or just WHERE.
- Exercises: Weekly Top 12 Most Popular Topics
- Pandas DataFrame: Exercises, Practice, Solution
- Conversion Tools
- SQL Exercises, Practice, Solution - SUBQUERIES
- C Programming Exercises, Practice, Solution : For Loop
- Python Exercises, Practice, Solution
- Python Data Type: List - Exercises, Practice, Solution
- C++ Basic: Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - exercises on Employee Database
- SQL Exercises, Practice, Solution - exercises on Movie Database
- SQL Exercises, Practice, Solution - exercises on Soccer Database
- C Programming Exercises, Practice, Solution : Recursion