Created
July 26, 2016 16:17
-
-
Save srajangarg/8c1e97da4f4b40787f2e9e04034bcdc2 to your computer and use it in GitHub Desktop.
DB Lab 1 Discprepancies
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
Your Answer: | |
with stable as | |
(select course_id, sec_id, year, semester, count(ID) as numstu from takes | |
group by course_id, sec_id, year, semester), | |
enrol(max_enroll) as | |
( | |
select max(numstu) from stable | |
) | |
select course_id, sec_id, year, semester, numstu from stable, enrol | |
where numstu = enrol.max_enroll; | |
Hide Instructor Answer | |
Instructor's Answer: | |
with enrollment as | |
(select course_id, sec_id, year, semester, count(*) as number | |
from takes | |
group by course_id, sec_id, year, semester), | |
maxnumber as ( | |
select max(number) as maxnum | |
from enrollment | |
) | |
select * | |
from enrollment, maxnumber | |
where number = maxnum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment