w3resource
SQL exercises

SQL Subquery Exercises: Display the employee name, employee id and salary of all employees who report to Payam

SQL SUBQUERY: Exercise-5 with Solution

Write a query to display the employee name ( first name and last name ), employee id and salary of all employees who report to Payam.

Sample table: employees


Sample Solution:

SELECT first_name, last_name, employee_id, salary  
FROM employees  
WHERE manager_id = 
(SELECT employee_id  
FROM employees  
WHERE first_name = 'Payam' 
);

Sample Output:

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

Practice Online


Query Visualization:

Duration:

Query visualization of Display the employee name, employee id and salary of all employees who report to Payam - Duration

Rows:

Query visualization of Display the employee name, employee id and salary of all employees who report to Payam - Rows

Cost:

Query visualization of Display the employee name, employee id and salary of all employees who report to Payam - Cost

Contribute your code and comments through Disqus.

Previous: Write a query to display the employee id, employee name (first name and last name ) for all employees who earn more than the average salary.
Next: Write a query to display the department number, name ( first name and last name ), job and department name for all employees in the Finance department.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming