MySQL Joins Exercises: Find the employee ID, job title, number of days between ending date and starting date for all jobs in department 90
MySQL Joins: Exercise-7 with Solution
Write a query to find the employee ID, job title, number of days between ending date and starting date for all jobs in department 90 from job history.
Sample table: job_history
Sample table: jobs
Code:
SELECT employee_id, job_title, end_date-start_date Days FROM job_history
NATURAL JOIN jobs
WHERE department_id=90;
Sample Output:
employee_id job_title Days 200 Administration Assistant 59700 200 Public Accountant 40530
MySQL Code Editor:
Structure of 'hr' database :
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous:Write a query to get the department name and number of employees in the department.
Next:Write a query to display the department ID and name and first name of manager.
What is the difficulty level of this exercise?
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework