Uploaded by bandra21

SQLfinalexamBrianAndradethankyou

advertisement
Final SQL Normalize Tables into 3: Complete Upload tables into MySQL: Complete
Create primary key: complete Use desc command: desc Final_Employee_Data_Fall2023; Feild Type Null Key Default (Null all the way down) Extra EmplidtextYES
FnametextYES
LnametextYES
DepartmenttextYES
Dept_Idint(11)YES
Business_UnittextYES
Unit_Idint(11)YES
PositiontextYES
GendertextYES
EthnicitytextYES
Ageint(11)YES
HireDatetextYES
ExitDatetextYES
Annual_SalarytextYES
Bonus_Percentageint(11)YES
CountrytextYES
StatetextYES
CitytextYES
Zipint(11)YES
AddresstextYES
RegiontextYES
(a) SELECT Emplid, Region, Department, Business_Unit, Position, Annual_Salary, Bonus_Percentage
FROM Final_Employee_Data_Fall2023
WHERE Position IN ('VP', 'AVP')
AND country = 'United States';
(b)
SELECT Emplid, Country, Position, Annual_Salary, Bonus_Percentage, (Annual_Salary + Bonus_Percentage) AS 'Total Salary'
FROM Final_Employee_Data_Fall2023
WHERE Country IN ('Brazil', 'China');
(c)
SELECT Country, Region, COUNT(*) AS number_of_employees
FROM Final_Employee_Data_Fall2023
WHERE Country = 'United States'
GROUP BY Country, Region;
(d)
SELECT Region, COUNT(*) AS Total_Employees
FROM Final_Employee_Data_Fall2023
GROUP BY Region
ORDER BY Total_Employees DESC
LIMIT 1;
(e) SELECT Country, Department, Business_Unit, Emplid, Fname, Lname, Position
FROM Final_Employee_Data_Fall2023
WHERE Business_Unit = 'Research & Development'
AND Department = 'IT'
AND Country = 'United States';
Download