w3resource
SQL exercises

SQL SORTING and FILTERING on HR Database: Display job ID for those jobs that were done by two or more for more than 300 days

SQL SORTING and FILTERING on HR Database: Exercise-24 with Solution

24. Write a query in SQL to display job ID for those jobs that were done by two or more for more than 300 days.

Sample table : job_history


Sample Solution:

SELECT job_id 
	FROM job_history 
		WHERE end_date-start_date >300 
			GROUP BY job_id 
				HAVING COUNT(*)>=2;

Sample Output:

   job_id
------------
 AC_ACCOUNT
 ST_CLERK
(2 rows)

Practice Online


HR database model

Query Visualization:

Duration:

Query visualization of Display job ID for those jobs that were done by two or more for more than 300 days - Duration

Rows:

Query visualization of Display job ID for those jobs that were done by two or more for more than 300 days - Rows

Cost:

Query visualization of Display job ID for those jobs that were done by two or more for more than 300 days - Cost

Contribute your code and comments through Disqus.

Previous: Write a query in SQL to display job ID, number of employees, sum of salary, and difference between highest salary and lowest salary for a job.
Next: Write a query in SQL to display the country ID and number of cities in that country we have.

What is the difficulty level of this exercise?



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