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 2
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
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
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
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
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
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
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
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
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
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
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
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
To add a new record to the tblLecturers table for a new lecturer, the SQL command would be: