Photo AI

Display the details of all the courses in the tblCourses table, that can accommodate 100 or more students - NSC Information Technology - Question 2 - 2023 - Paper 1

Question icon

Question 2

Display-the-details-of-all-the-courses-in-the-tblCourses-table,-that-can-accommodate-100-or-more-students-NSC Information Technology-Question 2-2023-Paper 1.png

Display the details of all the courses in the tblCourses table, that can accommodate 100 or more students. Example of output of the first five records: CourseID Co... show full transcript

Worked Solution & Example Answer:Display the details of all the courses in the tblCourses table, that can accommodate 100 or more students - NSC Information Technology - Question 2 - 2023 - Paper 1

Step 1

Button [2.1.1 - Large enrolments]

96%

114 rated

Answer

To display the details of all courses in the tblCourses table that can accommodate 100 or more students, you would use the following SQL query:

SELECT * FROM tblCourses
WHERE MaxStudents > 99;

Step 2

Button [2.1.2 - Lecturer gender]

99%

104 rated

Answer

To display the LecturerName, LecturerSurname, and the first letter of the gender of all the lecturers, the SQL query should be written as:

SELECT LecturerName, LecturerSurname, LEFT(Gender, 1) AS 'Gender (M/F)'
FROM tblLecturers;

Step 3

Button [2.1.3 - Multilingual lecturers]

96%

101 rated

Answer

In order to display the CourseID and CourseName of all courses that have a multilingual lecturer, the following SQL query can be used:

SELECT CourseID, CourseName
FROM tblCourses
INNER JOIN tblLecturers ON tblCourses.LecturerID = tblLecturers.LecturerID
WHERE tblLecturers.Multilingual = TRUE
ORDER BY CourseName;

Step 4

Button [2.1.4 - Lecturer salaries]

98%

120 rated

Answer

To display the LecturerID and total salary, formatted to currency, the SQL command would be:

SELECT LecturerID,
FORMAT(COUNT(*) * 10000, 'CURRENCY') AS Salary
FROM tblCourses
GROUP BY LecturerID;

Step 5

Button [2.2.1 - Average duration of courses]

97%

117 rated

Answer

To find the average duration of courses per lecturer, the SQL query should be structured as follows:

SELECT tl.LecturerID, tl.LecturerName, tl.LecturerSurname,
AVG(tc.Duration) AS 'Average duration of courses'
FROM tblLecturers tl
LEFT JOIN tblCourses tc ON tl.LecturerID = tc.LecturerID
GROUP BY tl.LecturerID, tl.LecturerName, tl.LecturerSurname;

Step 6

Button [2.2.2 - Register new lecturer]

97%

121 rated

Answer

To add a new record to the tblLecturers table for a new lecturer, the SQL command would be:

tblLecturers.Insert();
	LecturerID := 'ZT032';
	LecturerName := 'Zander';
	LecturerSurname := 'Thomas';
	Gender := 'Male';
	Multilingual := True;

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

;