Photo AI

The database EmployeesDB contains the information of the employees of an import and export company - NSC Information Technology - Question 2 - 2020 - Paper 1

Question icon

Question 2

The-database-EmployeesDB-contains-the-information-of-the-employees-of-an-import-and-export-company-NSC Information Technology-Question 2-2020-Paper 1.png

The database EmployeesDB contains the information of the employees of an import and export company. The database contains two tables called tblEmployees and tblHourL... show full transcript

Worked Solution & Example Answer:The database EmployeesDB contains the information of the employees of an import and export company - NSC Information Technology - Question 2 - 2020 - Paper 1

Step 1

Button (2.1.1 - List of employees)

96%

114 rated

Answer

To display all information of employees sorted by JobTitle and HourlyWage:

SELECT * FROM tblEmployees ORDER BY JobTitle, HourlyWage DESC;

Step 2

Button (2.1.2 - Engineers)

99%

104 rated

Answer

To display the required details of employees whose job title contains 'Engineer':

SELECT EmployeeID, LastName, FirstName FROM tblEmployees WHERE JobTitle LIKE '%Engineer%';

Step 3

Button (2.1.3 - Job titles)

96%

101 rated

Answer

To list all different job titles:

SELECT DISTINCT JobTitle FROM tblEmployees;

Step 4

Button (2.1.4 - Remove records)

98%

120 rated

Answer

To remove records with incorrect hours worked:

DELETE FROM tblHourLogs WHERE HoursWorked = 99;

Step 5

Button (2.1.5 - Overtime)

97%

117 rated

Answer

To calculate and display overtime payment:

SELECT LastName, FORMAT((SUM(HoursWorked - 8) * HourlyWage * 2), 'Currency') AS OvertimeAmt
FROM tblEmployees, tblHourLogs H
WHERE H.EmployeeID = tblEmployees.EmployeeID AND HoursWorked > 8
GROUP BY LastName;

Step 6

Button (2.2.1 - Employees with first aid)

97%

121 rated

Answer

To display employees who have completed first aid training:

SET @counter = 0;
SELECT EmployeeID, LastName, JobTitle FROM tblEmployees WHERE FirstAidTraining = TRUE;
SET @counter = @counter + 1;

-- Display counter
SELECT @counter AS 'Total number of employees with first aid training';

Join the NSC students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;