Browse Source

Adding a probably broken solution, but 1 left if i accept all as working

tarfeef101 7 years ago
parent
commit
faf745d3a8
1 changed files with 14 additions and 2 deletions
  1. 14 2
      a2/a2.sql

+ 14 - 2
a2/a2.sql

@@ -106,10 +106,22 @@ where c1.term = c2.term and c1.deptcode = c2.deptcode and c1.cnum = c2.cnum and
 /*
 Pairs of distinct professors such that whenever the first one teaches a class
 in a particular term the second also teaches a class for the same course
-in the same term. Report a oprofessor number and name for both the
+in the same term. Report a professor number and name for both the
 professors.
 */
-
+select pnum, pname, pnum2, pname2 from professor, (select pnum as pnum2, pname as pname2 from professor where pnum in
+    (
+      select pnum from class where deptcode = c.deptcode and cnum = c.cnum and term = c.term and pnum != c.pnum
+    )) as subquery where pnum in
+(
+  select pnum, deptcode, cnum, term from class c where exists
+  (
+    select pnum as pnum2, pname as pname2 from professor where pnum in
+    (
+      select pnum from class where deptcode = c.deptcode and cnum = c.cnum and term = c.term and pnum != c.pnum
+    )
+  )
+)
 
 -- NOW CAN USE AGGREGATION