Created
December 5, 2017 21:06
-
-
Save johnhonan/cee13aa8c8dc685c596e98905c88436b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT DISTINCT | |
job_history.employee_id, | |
employees.first_name, | |
x.max_start, | |
y.min_start | |
FROM hr.job_history | |
JOIN hr.employees | |
ON job_history.employee_id = employees.employee_id | |
JOIN | |
(SELECT employee_id, max(start_date) as max_start | |
FROM hr.job_history | |
GROUP BY employee_id) x | |
ON job_history.employee_id = x.employee_id | |
JOIN (SELECT employee_id, min(start_date) as min_start | |
FROM hr.job_history | |
GROUP BY employee_id) y | |
ON job_history.employee_id = y.employee_id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment