Test Feb13, 2017 Sample answers to query questions Two tests were distributed that differed slightly for questions 6 and 7 Question 6: Two different SQL statements but with the same join conditions Question 7: One variation asked for a list of part-time students The other asked for a list of full-time students Question 8: Two types of answers are shown The first is based on grouping; the other is based on joining a student to multiple sections of the same course 6. What is the equivalent Query Design View for SELECT Course.title, Section.deptCode, Count(Teaching.percentage) AS CountOfpercentage FROM Course INNER JOIN ((Room INNER JOIN ([Section] INNER JOIN Enrollment ON Section.sId = Enrollment.sId) ON Room.roomNo = Section.room) INNER JOIN Teaching ON Section.sId = Teaching.sId) ON (Course.courseNo = Section.courseNo) AND (Course.deptCode = Section.deptCode) GROUP BY Course.title, Section.deptCode, Room.roomNo HAVING (((Count(Enrollment.studentNo))>333)); 6. What is the equivalent Query Design View for SELECT Course.deptName, Section.sId, Count(Teaching.instructorNo) FROM Course INNER JOIN ((Room INNER JOIN ([Section] INNER JOIN Enrollment ON Section.sId = Enrollment.sId) ON Room.roomNo = Section.room) INNER JOIN Teaching ON Section.sId = Teaching.sId) ON (Course.courseNo = Section.courseNo) AND (Course.deptCode = Section.deptCode) GROUP BY Course.deptName, Room.roomNo, Section.sId HAVING (((Count(Enrollment.studentNo))>100)); 7. Design a query for: Financial Services at the UofW needs a list of all full time students. A full time student is one who is enrolled in at least 18 credit hours. The list must be in sequence by gender, then by last name and then by first name. Financial Services requires the listing to appear as shown to the right. The first ‘gender’ is for sorting purposes only … ‘show’ is not checked 7. Design a query for: Financial Services at the UofW needs a list of all part time students. A part time student is one who is enrolled in fewer than 18 credit hours. The list must be in sequence by gender, then by last name and then by first name. Financial Services requires the listing to appear as this example shows: The first ‘gender’ is for sorting purposes only … ‘show’ is not checked 8. Design a query for: In the past the Student Information System permitted students to enroll in more than one section of the same course. This caused a number of problems. We think the system does not allow this anymore, but to be sure the Registrar needs you to develop a query that would list any student who is enrolled in more than one section of the same course. The Registrar requires the listing to appear as shown to the right. Solution 1: Grouping by student and course and displaying when the number of rows in group is >1 8. Design a query for: In the past the Student Information System permitted students to enroll in more than one section of the same course. This caused a number of problems. We think the system does not allow this anymore, but to be sure the Registrar needs you to develop a query that would list any student who is enrolled in more than one section of the same course. The Registrar requires the listing to appear as shown to the right. Solution 2: One student joining to two different sections of the same course 9. Note the relationship between Enrollment and Student is based on student number, and referential integrity is being enforced. When the database administrator first tried to create this relationship it failed and the administrator saw the message: Show the query an administrator can run to list the rows in Enrollment that violate referential integrity. Outer join. Get all rows of Enrollment but where an enrollment row does not join to a student.
© Copyright 2026 Paperzz