Skip to content

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.

Notifications You must be signed in to change notification settings

AmanBanothe/HR-Employee-Attrition-Analysis-using-MySQL

Repository files navigation

πŸ’Ό HR Employee Attrition Analysis using MySQL

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.


πŸ“‚ Dataset

  • Source: IBM HR Analytics Dataset (Kaggle)
  • Format: CSV
  • Columns Used (selected):
    • Age, Attrition, BusinessTravel, Department, DistanceFromHome
    • Education, EnvironmentSatisfaction, JobRole, MonthlyIncome
    • OverTime, PerformanceRating, TotalWorkingYears, YearsAtCompany

πŸ›  Tools Used

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.

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published