SQL & Queries



Answer & solution
Answer: SELECT S.sdegree, AVG(O.osalary) AS avg_offered_salary FROM STUDENT S JOIN OFFER O ON O.srollno=S.srollno GROUP BY S.sdegree HAVING COUNT(DISTINCT S.srollno)>5; (no official key was published)
A query under the usual interpretation of average offered salary, averaging the offer records, is:
SELECT S.sdegree, AVG(O.osalary) AS avg_offered_salary
FROM STUDENT AS S JOIN OFFER AS O ON O.srollno=S.srollno
GROUP BY S.sdegree
HAVING COUNT(DISTINCT S.srollno)>5;
The join associates each offer with its student's degree. COUNT(DISTINCT S.srollno) implements more than five students, not more than five offers: the composite OFFER key permits several companies to offer jobs to one student. AVG(O.osalary) averages the offered salary values within the degree group. No JOIN to INTERVIEW is needed, because OFFER already identifies successful candidates.