0% found this document useful (0 votes)
27 views

DBMS Lab 4

DBMS Report

Uploaded by

metaeducator
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

DBMS Lab 4

DBMS Report

Uploaded by

metaeducator
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

NAME: SHUBHANSHU NISHAD

COURSE: BTECH CS CCV


ROLL NO: 21(P)

Solve the following:


Q1. Count the total number of Students.
Ans. SELECT COUNT(sName) FROM Student;

COUNT(SNAME)
12

Q2. Calculate the average GPA of all Student.


Ans. SELECT AVG(GPA) FROM Student;

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

SELECT Max(GPA) as min_GPA


FROM Student;

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

Q5. Find Maximum, Average, Minimum, total GPA of all student.


Ans. SELECT MAX(GPA),AVG(GPA),MIN(GPA)
FROM Student;

MAX(GPA) AVG(GPA) MIN(GPA)


3.9 3.56666666666666666666666666666666666667 2.9

Q6. Find total number of colleges in our Application Database.


Ans. SELECT COUNT(cName)
FROM Apply;

COUNT(CNAME)
19

Q7. Find how many different majors student had applied in.
Ans. SELECT COUNT(major)
FROM Apply;
COUNT(MAJOR)
19

Q8. Find total no. of Applications in our Application System’s Database.


Ans. SELECT COUNT(sID)
FROM Apply;

COUNT(sID)
19

Q9. Find average of all distinct GPA.


Ans. SELECT AVG(Distinct GPA)
FROM Student;

AVG(DISTINCTGPA)
3.54285714285714285714285714285714285714

Q10. Display the total number of application accepted.


Ans. SELECT COUNT(decision)
FROM Apply
WHERE decision='Y';

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

Q12. Find how many student applied to ‘marine biology’.


Ans. SELECT COUNT(major)
FROM Apply
WHERE major='marine biology';

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

Q14. Find how many students applied to a particular major. (show


count(sid) as
No_of_applications).
Ans. SELECT COUNT(sID) As No_of_applications
FROM Apply;
NO_OF_APPLICATIONS
19

Q15. Find number of applications received by particular college.


Ans. SELECT COUNT(cName)
FROM Apply ;

COUNT(CNAME)
19

Q16. Find number of applications received in a particular major at a


particular college.
Ans. SELECT COUNT(major)
FROM Apply ;

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.

SELECT GPA, COUNT(GPA) AS Frequency


FROM Student
GROUP BY GPA
ORDER BY GPA;
GPA FREQUENCY
2.9 2
3.4 2
3.5 1
3.6 1
3.7 1
3.8 1
3.9 4

You might also like