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 the complete information of employees ordered by JobTitle and HourlyWage in descending order, the following SQL query can be executed:

SELECT * FROM tblEmployees ORDER BY JobTitle, HourlyWage DESC;

Step 2

Button [2.1.2 - Engineers]

99%

104 rated

Answer

To select and display employees whose job title contains the word 'Engineer', the following SQL query can be used:

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

Step 3

Button [2.1.3 - Job titles]

96%

101 rated

Answer

To display a unique list of job titles from the employees table, use the following SQL query:

SELECT DISTINCT JobTitle FROM tblEmployees;

Step 4

Button [2.1.4 - Remove records]

98%

120 rated

Answer

To remove records from the tblHourLogs table where HoursWorked equals 99, execute:

DELETE FROM tblHourLogs WHERE HoursWorked = 99;

Step 5

Button [2.1.5 - Overtime]

97%

117 rated

Answer

To calculate and display the total amount each employee has earned in overtime, the following SQL query should be used:

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

Step 6

Button [2.2.1 - Employees with first aid]

97%

121 rated

Answer

To list the employees who completed first aid training, and count their number, implement the following code:

Writeln('EmployeeID', #9, 'LastName', #9, 'JobTitle');
Counter := 0;
for each record in tblEmployees do
begin
  if tblEmployees[FirstAidTraining] = True then
  begin
    Writeln(tblEmployees[EmployeeID], #9, tblEmployees[LastName], #9, tblEmployees[JobTitle]);
    Counter := Counter + 1;
  end;
end;
Writeln('Total number of employees who completed first aid training: ', Counter);

Step 7

Button [2.2.2 - Add new employee]

96%

114 rated

Answer

To add a new record for the employee Robert Laubscher with an ID and wage of EMP0986 and 15.00 respectively, use the following code:

tblEmployees.Insert;
tblEmployees[EmployeeID] := 'EMP0986';
tblEmployees[FirstName] := 'Robert';
tblEmployees[LastName] := 'Laubscher';
tblEmployees[HourlyWage] := 15.00;
tblEmployees[JobTitle] := 'Marine Engineer';
tblEmployees.Post;

Step 8

Button [2.2.3 - Update hours worked]

99%

104 rated

Answer

To update the hours worked in the tblHourLogs table, select the record and then input the new value:

var
  hours: Integer;
begin
  hours := StrToInt(Edit1.Text);  // Assume Edit1 is the input field
  tblHourLogs.Edit;
  tblHourLogs[HoursWorked] := hours;
tblHourLogs.Post;
end;

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

;