Advanced SQL: Employee Hires and Attrition
I have an employee roster, that I needed to compare month-over-month of who’s new (hires) and who left (attrition or turnover).
Original Solution
My original process was to run a SQL script, that created the dataset and placed it into a separate database table. This would be done manually each month once a new end-of-month roster became available.
Don’t worry coworkers; as with all examples, exact table names/fields are changed 😃
Proposed Solution
I ran into the problem where the original dataset kept changing, so I needed to constantly re-create the data. As you can see on lines 5 and 8 above, this would involve me updating the date and re-running the script for every month in my dataset.
I needed a solution where I could generate this data without the separate (extra) table:
New Hires:
Attrition / Turnover:
Final Solution
While the new/proposed solution works, I found other reasons to keep the old/original process. Specifically, I needed to massage the monthly data that required manual intervention.
At least now you, dear reader, have two solutions should you have this same need!