w3resource
SQL exercises

SQL Subquery Exercises: Display the details of the current job for those employees who worked as a Sales Representative in the past

SQL SUBQUERY: Exercise-51 with Solution

Write a query in SQL to display the details of the current job for those employees who worked as a Sales Representative in the past.

Sample table: jobs


Sample table: employees


Sample table: job_history


Sample Solution:

SELECT * 
	FROM jobs 
		WHERE job_id IN 
		(SELECT job_id 
			FROM employees 
				WHERE employee_id IN 
        (SELECT employee_id 
			FROM job_history 
				WHERE job_id='SA_REP'));

Sample Output:

job_id	job_title		min_salary	max_salary
SA_REP	Sales Representative	6000		12000

Practice Online


Query Visualization:

Duration:

Query visualization of Display the details of the current job for those employees who worked as a Sales Representative in the past - Duration

Rows:

Query visualization of Display the details of the current job for those employees who worked as a Sales Representative in the past - Rows

Cost:

Query visualization of Display the details of the current job for those employees who worked as a Sales Representative in the past - Cost

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a query in SQL to display the full name (first and last name) of manager who is supervising 4 or more employees.
Next: Write a query in SQL to display all the infromation about those employees who earn second lowest salary of all the employees.

What is the difficulty level of this exercise?



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