Answered step by step
Verified Expert Solution
Question
1 Approved Answer
- student(sid, sname, sex, age, year, gpa) [Year is a number between 1 and 5]. - dept( dname, numphds) - prof(pname, dname) - course(cno, cname,
- student(sid, sname, sex, age, year, gpa) [Year is a number between 1 and 5]. - dept( dname, numphds) - prof(pname, dname) - course(cno, cname, dname) [Course numbers are unique within departments.] - major(dname, sid) - section(dname, cno, sectno, pname) [Associates an instructor to a section.] - enroll(sid, grade, dname, cno, sectno) [Associates students to sections.] Write the following queries in SQL. We do not care if your answer contains duplicate rows or not, unless we specify otherwise. The use of temporary tables is not allowed for any query. a. Find department names and student sids where the student does not major in that department, but takes at least one class taught in that department. b. Find all the student information and the corresponding class information (including course name and grade) for students who enroll in the class and obtain a grade that is at least 1 whole point lower than their gpa. c. For each professor, calculate the average grade G of all students taught by that professor; for professors with a G value of at least 2.5, print the professor's name, department, total enrollment and average grade (i.e., G). Assume that the enrollment of a professor is the sum of the enrollment of all his/her sections. d. For each department, show information about the student(s) with the highest gpa who major in the department. In particular, for each such student, we want to show the student id, student name and gpa, the department name the student is major in, and the total number of classes that the student took. If there are ties, show all students with that gpa
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started