DBMS Lab 4
DBMS Lab 4
COUNT(SNAME)
12
AVG(GPA)
3.56666666666666666666666666666666666667
Q3. Determine the minimum and maximum GPA. Rename the titles as ‘max_GPA’
and
‘min_GPA’ respectively.
Ans. SELECT MIN(GPA) as max_GPA
FROM Student;
max_GPA
2.9
min_GPA
3.9
Q4. Count the number of students having GPA greater than or equal to 3.7.
Ans. SELECT COUNT(GPA)
FROM Student
WHERE GPA>=3.7;
COUNT(GPA)
6
COUNT(CNAME)
19
Q7. Find how many different majors student had applied in.
Ans. SELECT COUNT(major)
FROM Apply;
COUNT(MAJOR)
19
COUNT(sID)
19
AVG(DISTINCTGPA)
3.54285714285714285714285714285714285714
COUNT(DECISION)
11
Q11. Find number of students having GPA>3.4 and coming from high school
having
size>1000.
Ans. SELECT COUNT(sName)
FROM Student
WHERE GPA>3.4 AND sizeHS>1000;
COUNT(SNAME)
1
COUNT(MAJOR)
1
Q13. Find how many applications were rejected and accepted by the
colleges.
Ans. SELECT COUNT(decision)
FROM Apply
WHERE decision='N' AND decision='Y';
COUNT(DECISION)
0
COUNT(CNAME)
19
COUNT(MAJOR)
19
Q17. Give the college name and major, where number of applications
received are greater
than or equal to 2.
Ans. SELECT COUNT(cName),COUNT(major)
FROM Apply
WHERE cName>=2;
COUNT(CNAME) COUNT(MAJOR)
0 0
Q21. Find how many applications are filed by each student. [Hint: use
left join as we need
information about all 12 students here. If they applied no where than
show zero in
front of them]
Ans. SELECTStudent.sName,Count(Apply.sID)
FROM Student
Left JOIN Apply
ON Student.sID = Apply.sID
Group By Student.sName
;
SNAME COUNT(APPLY.SID)
Amy 4
Bob 1
Helen 2
Gary 0
Craig 5
Fay 1
Jay 3
Doris 0
Irene 3
Edward 0
Q22. Provide name of students that file 3 or more applications.
Ans. SELECT Student.sName,Count(Apply.sID)
FROM Student
Left JOIN Apply
ON Student.sID = Apply.sID
Group By Student.sName
Having Count(Apply.sID) > 3;
SNAME COUNT(APPLY.SID)
Amy 4
Craig 5
Q23. Provide name of student who have not applied to any college.
Ans. SELECT Student.sName
FROM Student
LEFT JOIN Apply
ON Student.sID = Apply.sID
WHERE Apply.sID IS NULL
SNAME
Edward
Amy
Doris
Gary
Q25. Find how many student have same GPA among all students. (provide
this frequency
in two column table as GPA 3.9 is 4 times, GPA 2.9 is 2 times ).
Ans.