Created
March 6, 2014 03:11
-
-
Save JALsnipe/29dd0dab696198109b4f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * | |
FROM (SELECT s.cno, s.dname | |
FROM section s, prof p, enroll e | |
WHERE s.cno = e.cno AND s.dname = p.dname AND s.dname = e.dname AND s.dname IN( | |
SELECT m.dname | |
FROM major m | |
GROUP BY m.dname | |
HAVING COUNT(*) > 8) | |
GROUP BY s.cno, s.dname | |
) majors_eight, | |
(SELECT MAX(enrollment) as max_enroll, dname | |
FROM( | |
SELECT s.dname, s.cno, s.sectno, COUNT(*) as enrollment | |
FROM section s, enroll e | |
WHERE s.dname = e.dname AND s.cno = e.cno AND s.sectno = e.sectno | |
GROUP BY s.dname, s.cno, s.sectno) | |
GROUP BY dname | |
) max_enroll | |
WHERE majors_eight.dname = max_enroll.dname AND majors_eight.enroll = max_enroll.max_enroll |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment