w3resource
SQL exercises

SQL Subquery Exercises: Display the employee name, employee id, and job title for all employees whose department location is Toronto

SQL SUBQUERY: Exercise-16 with Solution

Display the employee name( first name and last name ), employee id, and job title for all employees whose department location is Toronto.

Sample table: employees


Sample table: departments


Sample table: locations


Sample Solution:

SELECT  first_name, last_name, employee_id, job_id  
FROM employees  
WHERE department_id = 
(SELECT department_id  
FROM departments 
WHERE location_id = 
(SELECT location_id 
FROM locations  
WHERE city ='Toronto'));

Sample Output:

first_name	last_name	employee_id	job_id
Michael		Hartstein	201		MK_MAN
Pat		Fay		202		MK_REP

Practice Online


Query Visualization:

Duration:

Query visualization of Display the employee name, employee id, and job title for all employees whose department location is Toronto - Duration

Rows:

Query visualization of Display the employee name, employee id, and job title for all employees whose department location is Toronto - Rows

Cost:

Query visualization of Display the employee name, employee id, and job title for all employees whose department location is Toronto - Cost

Contribute your code and comments through Disqus.

Previous: Write a query to display the employee number, name( first name and last name ), and salary for all employees who earn more than the average salary and who work in a department with any employee with a 'J' in their name.
Next: Write a query to display the employee number, name( first name and last name ) and job title for all employees whose salary is smaller than any salary of those employees whose job title is MK_MAN.

What is the difficulty level of this exercise?



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