Meta's People Analytics team wants a simple attrition report by department. Write a SQL query that joins three tables to show headcount, attrition, and attrition rate for each department.
employees, departments, and employment_events tables.termination eventattrition_rate as terminated employees divided by total employees, rounded to 2 decimal places.attrition_rate descending, then department_name ascending.| Column | Type | Description |
|---|---|---|
| department_idPK | INT | Unique department identifier |
| department_name | VARCHAR(100) | Department name |
| org | VARCHAR(100) | Meta organization name |
| Column | Type | Description |
|---|---|---|
| employee_idPK | INT | Unique employee identifier |
| employee_name | VARCHAR(100) | Employee full name |
| department_id | INT | Department assignment |
| hire_date | DATE | Employee hire date |
| location | VARCHAR(100) | Primary office location |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique employment event identifier |
| employee_id | INT | Employee tied to the event |
| event_type | VARCHAR(50) | Type of event such as hire, transfer, or termination |
| event_date | DATE | Date of the event |
| reason | VARCHAR(100) | Reason associated with the event |