Skip to content

Commit be7fc27

Browse files
authored
commit
1 parent c706247 commit be7fc27

10 files changed

+146
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
-- Select all records from employeedata in the empreport
2+
SELECT * FROM empreport.employeedata;
3+
4+
-- If the uodate not working input this code but after back again this is for safety reasonn
5+
SET sql_safe_updates = 0;
6+
7+
8+
-- Change column name from 'ID' to 'Employee_ID' and adjust data type
9+
ALTER TABLE employeedata
10+
CHANGE COLUMN ID Employee_ID VARCHAR(15) NULL;
11+
12+
-- Display column details to check data types before altering
13+
DESCRIBE employeedata;
14+
15+
SELECT Birth_Date from employeedata;
16+
17+
-- Update and format 'Birth_Date' from MM/DD/YYYY and MM-DD-YYYY to YYYY-MM-DD
18+
UPDATE empreport.employeedata
19+
SET Birth_Date = CASE
20+
WHEN Birth_Date Like '%/%' THEN date_format(STR_TO_DATE(Birth_Date, '%m/%d/%Y'), '%Y/%m/%d')
21+
WHEN Birth_Date Like '%-%' THEN date_format(STR_TO_DATE(Birth_Date, '%m-%d-%Y'), '%Y-%m-%d')
22+
ELSE NULL
23+
END;
24+
25+
-- Modify 'Birth_Date' column to DATE type after ensuring data is properly formatted
26+
ALTER TABLE empreport.employeedata
27+
MODIFY COLUMN Birth_Date DATE;
28+
29+
-- Add an 'Age' column calculated from 'Birth_Date'
30+
ALTER TABLE employeedata ADD COLUMN Age int;
31+
32+
-- Calculate age based on 'Birth_Date' using current date
33+
UPDATE empreport.employeedata
34+
SET Age = TIMESTAMPDIFF(YEAR, Birth_Date, CURDATE());
35+
36+
-- Display birth dates and corresponding ages to verify correctness
37+
SELECT Birth_Date, Age FROM empreport.employeedata;
38+
39+
-- Find the youngest and oldest employees in the dataset
40+
SELECT
41+
MIN(Age) AS Youngest_Age,
42+
MAX(Age) AS Oldest_Age
43+
FROM empreport.employeedata;
44+
45+
-- Select employees over 60 years old to view their first name, age, and birth date
46+
SELECT First_Name, Age, Birth_Date
47+
FROM empreport.employeedata
48+
WHERE Age > 60;
49+
50+
-- Re-enable safe updates after maintenance
51+
SET sql_safe_updates = 1;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Job_Title,Average_Salary
2+
"BI Data Analyst",77182
3+
"Business Data Analyst",69200
4+
"Compliance Data Analyst",45000
5+
"Data Analyst",94430
6+
"Financial Data Analyst",80300
7+
"Marketing Data Analyst",200000
8+
"Sales Data Analyst",60000
9+
"Staff Data Analyst",97499
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Company_Size,Minimum_Salary,Maximum_Salary,Average_Salary
2+
M,15000,166000,86720
3+
L,17000,180000,83958
4+
S,36000,200000,87889
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
-- Employee Salary Analysis and Visualization
2+
3+
-- Select all records from employeedata in the empreport
4+
SELECT * FROM empreport.employeedata;
5+
6+
-- 1. What is the total number of employees, and how many are there in each job title?
7+
-- This helps to understand the distribution of employees across different roles.
8+
-- Use a Card and Matrix Chart to easily count the total number of employees and the count in each job title.
9+
SELECT Job_Title, COUNT(*) AS Employee_Count
10+
FROM empreport.employeedata
11+
GROUP BY Job_Title;
12+
13+
-- 2. What is the average salary by Job title?
14+
-- This highlight compensation trends across different positions.
15+
SELECT Job_Title, ROUND(AVG(Salary), 0) AS Average_Salary
16+
FROM EmployeeData
17+
GROUP BY Job_Title
18+
ORDER BY Job_Title ASC;
19+
20+
-- 3. What is the distribution of experience levels within the company?
21+
-- Understanding the distribution of experience can aid in planning for training and development.
22+
-- Use a Pie Chart to show the proportion of each experience level within the company, providing a quick view of the distribution.
23+
-- Use a Stacked Bar Chart to compare average salaries side-by-side for males and females across various job roles or departments.
24+
SELECT Experience_Level, COUNT(*) AS Count
25+
FROM EmployeeData
26+
GROUP BY Experience_Level;
27+
28+
-- 4. What are the common work settings and their salaries?
29+
-- This can show if remote work settings influence salaries differently.
30+
-- Clustered Column Chart show average salaries for different work settings and show the count of employees in each setting.
31+
SELECT Work_Setting, ROUND (AVG(Salary), 0) AS Average_Salary, COUNT(*) AS Employee_Count
32+
FROM EmployeeData
33+
GROUP BY Work_Setting;
34+
35+
-- 5. How does employee distribution vary by location?
36+
-- Identifying if certain locations have more employees can influence regional policies.
37+
-- Use a Treemap chart to show the distribution across different regions.
38+
SELECT Location, COUNT(*) AS Employee_Count
39+
FROM EmployeeData
40+
GROUP BY Location;
41+
42+
43+
-- 6. What is the salary range within each company size category?
44+
-- Examining how salary ranges differ between small, medium, and large companies.
45+
-- Display the distribution of salaries, highlighting the median, quartiles, and outliers within each company size category.
46+
SELECT Company_Size,
47+
MIN(Salary) AS Minimum_Salary,
48+
MAX(Salary) AS Maximum_Salary,
49+
ROUND(AVG(Salary), 0) AS Average_Salary
50+
FROM EmployeeData
51+
GROUP BY Company_Size;
52+
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Location,Employee_Count
2+
"United States",37
3+
Poland,1
4+
Canada,2
5+
India,1
6+
Russia,1
7+
Ghana,1
8+
Nigeria,3
9+
"United Kingdom",1
10+
"Saudi Arabia",1
11+
Netherlands,1
12+
Kenya,1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Experience_Level,Count
2+
Entry-level,18
3+
Senior,13
4+
Mid-level,17
5+
Executive,2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Job_Title,Employee_Count
2+
"Data Analyst",23
3+
"Business Data Analyst",5
4+
"Financial Data Analyst",5
5+
"Marketing Data Analyst",1
6+
"Staff Data Analyst",2
7+
"Sales Data Analyst",1
8+
"Compliance Data Analyst",2
9+
"BI Data Analyst",11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Work_Setting,Average_Salary,Employee_Count
2+
In-person,80169,17
3+
Remote,94964,28
4+
Hybrid,58300,5

0 commit comments

Comments
 (0)