Browse Source

more testing info/changes

tsdedhar 6 years ago
parent
commit
e03612be5b
2 changed files with 17 additions and 5 deletions
  1. 7 3
      a2/a2.sql
  2. 10 2
      a2/test.sql

+ 7 - 3
a2/a2.sql

@@ -111,12 +111,13 @@ in a particular term the second also teaches a class for the same course
 in the same term. Report a professor number and name for both the
 in the same term. Report a professor number and name for both the
 professors.
 professors.
 */
 */
+-- not working, c.deptcode not valid somewhere
 select pnum, pname, pnum2, pname2 from professor, (select pnum as pnum2, pname as pname2 from professor where pnum in
 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
       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
     )) as subquery where pnum in
 (
 (
-  select pnum, deptcode, cnum, term from class c where exists
+  select c.pnum, c.deptcode, c.cnum, c.term from class c where exists
   (
   (
     select pnum as pnum2, pname as pname2 from professor where pnum in
     select pnum as pnum2, pname as pname2 from professor where pnum in
     (
     (
@@ -133,6 +134,7 @@ course. Also, include only those course numbers for courses with a total
 enrollment count among the three lowest such counts.
 enrollment count among the three lowest such counts.
 */
 */
 -- Not sure if this will return an error, or 3 rows per old.deptcode, old.cnum since the 3rd parameter (the subquery) has 3 rows
 -- Not sure if this will return an error, or 3 rows per old.deptcode, old.cnum since the 3rd parameter (the subquery) has 3 rows
+-- didn't break running on an empty dataset
 select old.deptcode, old.cnum, (select count(*) from enrollment where deptcode = old.deptcode and cnum = old.cnum group by deptcode, cnum order by count(*) asc limit 3) from class old;
 select old.deptcode, old.cnum, (select count(*) from enrollment where deptcode = old.deptcode and cnum = old.cnum group by deptcode, cnum order by count(*) asc limit 3) from class old;
 
 
 /*
 /*
@@ -140,7 +142,7 @@ The percentage of professors in pure math who have always taught no
 more than a single course in any given term. (Note that a percentage
 more than a single course in any given term. (Note that a percentage
 should be a number between 0 and 100.)
 should be a number between 0 and 100.)
 */
 */
-
+-- not liking the formatting
 select (select count(*) from professor p where deptcode = 'PM' and pnum in
 select (select count(*) from professor p where deptcode = 'PM' and pnum in
 (
 (
   select c.pnum, c.deptcode, c.cnum, c.term, c.section from class c where c.pnum = p.pnum and c.pnum not in
   select c.pnum, c.deptcode, c.cnum, c.term, c.section from class c where c.pnum = p.pnum and c.pnum not in
@@ -148,7 +150,7 @@ select (select count(*) from professor p where deptcode = 'PM' and pnum in
     select c1.pnum, c1.deptcode, c1.cnum, c1.term, c1.section from class c1 where pnum = p.pnum and c1.term = c.term and (c1.deptcode != c.deptcode or c1.cnum != c.cnum)
     select c1.pnum, c1.deptcode, c1.cnum, c1.term, c1.section from class c1 where pnum = p.pnum and c1.term = c.term and (c1.deptcode != c.deptcode or c1.cnum != c.cnum)
   )
   )
 ))
 ))
-/ (select count(*) from professor where deptcode = 'PM') as percentage;
+/ (select count(*) from professor where deptcode = 'PM');
 
 
 /*
 /*
 The number of different third or fourth year students in each section of
 The number of different third or fourth year students in each section of
@@ -160,6 +162,7 @@ section. (Note that a section is identified by a term and a section number.
 Also assume that sorting by section means sorting by term and then by
 Also assume that sorting by section means sorting by term and then by
 section number. The result will therefore have a total of six columns.)
 section number. The result will therefore have a total of six columns.)
 */
 */
+-- ran on empty dataset
 select (select pname from professor where pnum = c.pnum), c.pnum, c.cnum, c.term, c.section,
 select (select pname from professor where pnum = c.pnum), c.pnum, c.cnum, c.term, c.section,
   (select count(distinct snum) from mark where snum in
   (select count(distinct snum) from mark where snum in
   (
   (
@@ -198,4 +201,5 @@ with a particular number of classes. For example an output
 indicates that there are 5 courses with a single class (section), 4 courses
 indicates that there are 5 courses with a single class (section), 4 courses
 with 2 classes, and 1 course with 5 classes scheduled in the curent term.
 with 2 classes, and 1 course with 5 classes scheduled in the curent term.
 */
 */
+-- ran on empty dataset
 select count(*), count(distinct section) from schedule where term = 1185;
 select count(*), count(distinct section) from schedule where term = 1185;

+ 10 - 2
a2/test.sql

@@ -1,2 +1,10 @@
--- db2 -tvmf test.sql is how to run test query
-select count(*), count(distinct section) from schedule where term = 1185;
+-- run this to use test: db2 -tvmf test.sql
+select (select pname from professor where pnum = c.pnum), c.pnum, c.cnum, c.term, c.section,
+  (select count(distinct snum) from mark where snum in
+  (
+    select snum from student where year between 3 and 4
+  ) and deptcode = c.deptcode and cnum = c.cnum and term = c.term and section = c.section)
+from class c where pnum in
+(
+  select pnum from professor where deptcode = 'PM'
+) and term != 1185;