This project is a comprehensive HR analytics case study using MySQL, based on IBM's HR dataset. The goal is to identify trends, patterns, and drivers of employee attrition, helping HR teams make data-driven decisions to improve retention.
- Source: IBM HR Analytics Dataset (Kaggle)
- Format: CSV
- Columns Used (selected):
Age
,Attrition
,BusinessTravel
,Department
,DistanceFromHome
Education
,EnvironmentSatisfaction
,JobRole
,MonthlyIncome
OverTime
,PerformanceRating
,TotalWorkingYears
,YearsAtCompany
Tool | Purpose |
---|---|
MySQL | Data storage and analysis |
Excel | Preprocessing CSV (optional) |
GitHub | Project documentation |
π Project Objectives
- Identify key factors contributing to employee attrition.
- Segment high-risk employee groups.
- Suggest actionable retention strategies using data.
π Key SQL Queries and Insights
β Attrition Rate by Department
π‘ Insight: Departments like Sales or R&D have higher attrition β worth deeper investigation.
SELECT Department, COUNT() AS Total_Employees, SUM(CASE WHEN Attrition = 'Yes' THEN 1 ELSE 0 END) AS Attritions, ROUND(SUM(CASE WHEN Attrition = 'Yes') * 100.0 / COUNT(), 2) AS Attrition_Rate FROM hr_attrition GROUP BY Department;
β Income Group vs Attrition
π‘ Insight: Lower income groups show significantly higher attrition.
SELECT CASE WHEN MonthlyIncome < 3000 THEN 'Low Income' WHEN MonthlyIncome BETWEEN 3000 AND 6000 THEN 'Mid Income' ELSE 'High Income' END AS Income_Bracket, COUNT() AS Total, SUM(CASE WHEN Attrition = 'Yes' THEN 1 ELSE 0 END) AS Attritions, ROUND(SUM(CASE WHEN Attrition = 'Yes') * 100.0 / COUNT(), 2) AS Attrition_Rate FROM hr_attrition GROUP BY Income_Bracket;
β High Risk Attrition Profile (Custom Scoring)
π‘ Insight: Employees with low pay, long commute, and overtime are most at risk.
SELECT * FROM hr_attrition WHERE MonthlyIncome < 3000 AND DistanceFromHome > 10 AND OverTime = 'Yes';
β Job Role + Department Attrition Hotspots
π‘ Insight: Focus on specific job-department pairs that drive attrition.
SELECT Department, JobRole, ROUND(SUM(CASE WHEN Attrition = 'Yes' THEN 1 ELSE 0 END)100.0 / COUNT(), 2) AS Attrition_Rate FROM hr_attrition GROUP BY Department, JobRole ORDER BY Attrition_Rate DESC LIMIT 5;
π‘ More Queries:
- Overall Attrition Rate
- Attrition by Job Role
- Attrition by Age Group
- Impact of Overtime on Attrition
- Attrition by Distance from Home
- Monthly Income vs Attrition (Income brackets)
- Attrition by Department
- Job Role vs Monthly Income
- Attrition by Education Level
- Total Working Years vs Attrition
- Years at Company Grouped
- Performance Rating vs Attrition
- High Risk Employees (Low Income + High Distance + Overtime) #Advanced analyze
- Which combination of Job Role & Department shows highest attrition?
- Compare average tenure (YearsAtCompany) of employees who left vs stayed
- Attrition Risk Score (Custom Score Calculation)
- Employees with High Performance but Still Left
- Average Income vs Years of Experience (Working Years)
- Attrition by Distance Buckets
- Correlation between Environment Satisfaction & Attrition
- Cohort Analysis: Who joined <2 years ago and already left?
- Are young employees leaving more frequently?
- Employee Retention Ratio by Job Role
π Key Insights
- OverTime is a strong attrition driver.
- Low-income and high-distance employees show higher turnover.
- New employees (0-2 years) leave more often β signaling onboarding/culture-fit issues.
- Some high-performing, well-paid employees still leave β possible job dissatisfaction or leadership gap.
- Helps HR target specific job roles within departments for retention strategies.
- Reveals whether long-serving employees or new joiners are leaving more.
- Use this to segment employees for proactive retention programs.
- Losing top performers is costlyβthis helps flag critical losses.
- Useful for HR compensation benchmarking.
- Helps HR with location-based working policy (WFH/flex commute).
- Poor workplace experience often correlates with employee churn.
β Conclusion
Using simple yet powerful SQL analytics, this project uncovers valuable trends hidden in HR data. The goal is to help HR departments identify, understand, and act on attrition patterns β improving employee engagement and reducing talent loss.
π Project Structure
π¦ HR-Attrition-MySQL
β£ π data
β β hr_attrition.csv
β£ π queries.sql
β£ π insights.md
β£ π README.md
β Author
Aman Banothe
π LinkedIn : https://www.linkedin.com/in/aman-banothe-5174ba223/
π§ Data Analyst | Power BI | MySQL | Tableau | Python
β Want to go further? Build a Power BI or Tableau dashboard from this dataset and add a short case-study video or presentation to your portfolio.
Would you like me to now generate:
π insights.md
(for detailed query + insight documentation), or- Start the next MySQL project:
AdventureWorks Sales Analysis
?
Just tell me: insights.md
or Next Project
.