A MySQL-based project simulating a company's HR database, covering employees, departments, and job roles. Includes 17 real-world business queries — from basic filtering to joins, subqueries, aggregations, and window functions.
3 Tables:
| Table | Description |
|---|---|
employees |
Employee records — name, email, hire date, job, salary, manager, department |
departments |
Department name and location |
jobs |
Job titles with min/max salary range |
Relationships:
employees.department_id→departments.department_idemployees.job_id→jobs.job_idemployees.manager_id→employees.employee_id(self-referencing, for manager hierarchy)
- MySQL
HR-Management-SQL-Project/
├── schema.sql -- Table definitions (DDL)
├── data.sql -- Sample data (DML)
├── queries.sql -- All 17 solved business questions
└── README.md
- Run
schema.sqlto create the tables. - Run
data.sqlto insert sample records. - Run any query from
queries.sqlto test the results.
- Employees earning more than 80,000
- Employees assigned to the IT or Marketing departments
- Employees who are not assigned to the IT department
- Top 3 highest-paid employees
- Employees whose first name starts with "A"
- Employees in IT or HR department using
IN - Employee summary report with readable alias names
- Combined result set of employees and managers (self-join)
- Count of employees in each department
- Departments with more than 1 employee
- All departments and their employees (LEFT JOIN)
- Employees earning more than their department's average salary
- Employee full name, job title, and department name
- Employee with manager name (fallback for no manager)
- Rank employees by salary company-wide
- Rank employees by salary within each department
- Top earner in every department using a CTE
Ashutosh Shrivastava