AdvancedDatabaseConcepts-Assignment-2-Solution
AdvancedDatabaseConcepts-Assignment-2-Solution
Homework 2
(Q1) Find the sids and names of all students who never got a grade lower than A- (A- is OK).
Q2 Find the students who have never taken any course that is not required by his/her department
Q3 For each department, find the name of the students with the highest GPA (if more than one
student has the same GPA, return them all)
Q4 A student can get the degree from his/her department if he/she has taken a total of 90 credit
hours’ courses, has a overall GPA over 2.0, and has taken all required courses. Please find the
sids and names of the students who can get the degree from their department.
1
INTERSECT
SELECT T.sid,T.cid FROM Take as T,RequiredCourse as RC
WHERE S1.sid = T.sid and T.cid=RC.cid) and
EXISTS(
SELECT SUM(C.credit) FROM Students as S,Take as T, Courses as C
WHERE S1.sid = S.sid and S.sid=T.sid and T.cid = C.cid
GROUP BY S.sid
HAVING SUM(C.credit)>=90)
A student will be returned if GPA is greater than two; and does not exists any recored
in the intersection between the required courses of the student’s department and the
required courses the student has taken; and we can calculate the student’s sum of courses’
credits to be greater or equal than 90.
Q5 (bonus) Find the courses (cid and name) that are required by more than 10 departments for
its degree program.