Skip to content
Advertisement

SQL Query to find the previous job , location of a particular job type

I have the below table with data –

I want to create a query that displays the employees that had previous job as student and were then converted to “Employee” even if the final status is ACTIVE/INACTIVE

I want to create a query that displays the below employees –

The above output, should show if previous job has anyting like “Student” mentioned. The previous_location , job sould have the latest location and job from the time when the job was “student/part-student”. and current_eff_start should have the latest effective date of the employee.

if the student changes its job to anything apart from “employee” like “contractor” then it should not be picked.

Advertisement

Answer

Try below, try to improve the code if you want:

Fiddle

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement