w3resource
SQL exercises

SQL JOINS on HR Database: Display the details of jobs which was done by any of the employees who is presently earning a salary on and above 12000

SQL JOINS on HR Database: Exercise-20 with Solution

20. Write a query in SQL to display the details of jobs which was done by any of the employees who is presently earning a salary on and above 12000.

Sample table: employees

Sample table: job_history

Sample Solution:

SELECT a.*
	FROM  job_history a 
		JOIN employees m 
			ON (a.employee_id = m.employee_id)
WHERE salary >= 12000;

Sample Output:

employee_id	start_date	end_date	job_id	department_id
101		1997-09-21	2001-10-27	AC_ACCOUNT	110
101		2001-10-28	2005-03-15	AC_MGR		110
102		2001-01-13	2006-07-24	IT_PROG		60
201		2004-02-17	2007-12-19	MK_REP		20

Practice Online


HR database model

Query Visualization:

Duration:

Query visualization of Display the details of jobs which was done by any of the employees who is presently earning a salary on and above 12000 - Duration

Rows:

Query visualization of Display the details of jobs which was done by any of the employees who is presently earning a salary on and above 12000 - Rows

Cost:

Query visualization of Display the details of jobs which was done by any of the employees who is presently earning a salary on and above 12000 - Cost

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

Previous: Write a query in SQL to display job title and average salary of employees.
Next: Write a query in SQL to display the country name, city, and number of those departments where at leaste 2 employees are working.

What is the difficulty level of this exercise?



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