w3resource
SQL exercises

SQL SORTING and FILTERING on HR Database: Display the employee ID and the date on which he ended his previous job

32. Write a query in SQL to display the employee ID and the date on which he ended his previous job.

Sample table : job_history


Sample Solution:

SELECT employee_id, MAX(end_date) 
	FROM job_history 
		GROUP BY employee_id;

Sample Output:

 employee_id |    max
-------------+------------
         122 | 2007-12-31
         201 | 2007-12-19
         101 | 2005-03-15
         114 | 2007-12-31
         176 | 2007-12-31
         102 | 2006-07-24
         200 | 2006-12-31
(7 rows)

Practice Online


HR database model

Query Visualization:

Duration:

Query visualization of Display the employee ID and the date on which he ended his previous job - Duration

Rows:

Query visualization of Display the employee ID and the date on which he ended his previous job - Rows

Cost:

Query visualization of Display the employee ID and the date on which he ended his previous job - Cost

Contribute your code and comments through Disqus.

Previous: Write a query in SQL to display those departments where more than ten employees work who got a commission percentage.
Next: Write a query in SQL to display the details of the employees who have no commission percentage and salary within the range 7000 to 12000 and works in that department which number is 50.

What is the difficulty level of this exercise?



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