Task
A company is integrating a new workforce planning platform with its existing HR system. Write a SQL query to ensure data accuracy by identifying discrepancies in employee records between the two systems.
Requirements
- Join the
employees table from the HR system with the workforce_planning table using employee_id.
- Identify employees that exist in the HR system but are missing from the workforce planning platform.
- Include a flag to indicate if the employee is active in the HR system.
- Return only those employees with discrepancies in their records.
Schema
employees (employee_id, name, active, department)
| employee_id | name | active | department |
|---|
| 1 | Alice | true | Sales |
| 2 | Bob | false | HR |
| 3 | Charlie | true | IT |
| 4 | Diana | true | Marketing |
workforce_planning (employee_id, name, position)
| employee_id | name | position |
|---|
| 1 | Alice | Manager |
| 3 | Charlie | Developer |
| 5 | Eve | Designer |
Expected Output
| employee_id | name | active | discrepancy |
|---|
| 2 | Bob | false | Missing from workforce planning |
| 4 | Diana | true | Missing from workforce planning |