-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQLQuery1.sql
More file actions
77 lines (48 loc) · 1.46 KB
/
Copy pathSQLQuery1.sql
File metadata and controls
77 lines (48 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
use Hr_Data_Analyst;
select * from hrdata;
-- Counting Total Employess
select count(distinct emp_no) as Employee_Count from hrdata;
-- Counting Total Attrition
select count(attrition)
as Attrition_Count from hrdata
where attrition = 1
;
-- Counting Attrition Rate
select ( (select count(attrition) from hrdata where attrition = 1 )*1.0 /
sum(employee_count))*100 as 'Attrition Rate'
from hrdata
;
-- Active Employees
select count(active_employee) as 'Avg. Age'
from hrdata where active_employee = 1;
-- Avg. Age
select sum(age) / count(emp_no) as 'Active Employee' from hrdata where active_employee = 1;
-- Attrition By Gender
select gender , count(attrition) as Attrition_Count from hrdata
where attrition= 1
group by gender
order by count(attrition) desc
;
-- Department wise Attrition
select department , count(attrition) as Attrition_Count from hrdata
where attrition= 1
group by department
order by count(attrition) desc
;
-- No of employees by Age Group
select age , count(attrition) as Attrition_Count from hrdata
where attrition= 1
group by age
order by count(attrition) desc
;
-- Education Field Wise Attrition
select education , count(attrition) as Attrition_Count from hrdata
where attrition= 1
group by education
order by count(attrition) desc
;
-- Job Satisfaction Rating
select job_role , job_satisfaction, count(job_satisfaction) as 'Total Rating'
from hrdata
group by job_satisfaction, job_role
;