0% found this document useful (0 votes)
41 views13 pages

Ass 4

Uploaded by

Ishu Agrawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views13 pages

Ass 4

Uploaded by

Ishu Agrawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

GLA UNIVERSITY , MATHURA

Name : ISHU AGRAWAL

Section : CA

Roll No. : 24

University Roll No. : 2315510088

Course : BTECH. CS ( AIML & IOT )

Subject : DATABASE MANAGEMENT SYSTEM LAB

Subject Code : BCSC 0762

Assignment : 04

Faculty : MR. SURENDRA KUMAR


1. count the total number of Students.
Ans: select count(*) from student;

2. Calculate the average GPA of all Student.


Ans: select avg(gpa) from student;

3. Determine the minimum and maximum GPA. Rename the


titles as ‘max_GPA’ and ‘min_GPA’ respectively.
Ans: select max(gpa) as max_GPA, min(gpa) as min_GPA from
student;

4. count the number of students having GPA greater than or


equal to 3.7.
Ans: select count(*) from student where gpa >= 3.7;
5. Find maximum, Average, minimum, total GPA of all student.
Ans: select max(gpa), avg(gpa), min(gpa), SUM(gpa) from
student;

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


Ans: select count(DISTINCT cname) from apply;

7. Find how many different majors students had applied in.


Ans: select count(DISTINCT major) from apply;

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


Database.
Ans: select count(*) from apply;
9. Find average of all distinct GPA.
Ans: select avg(DISTINCT gpa) from student;

10. Display the total number of application accepted.


Ans: select count(decision) from apply where decision='Y';

11. Find number of students having GPA>3.4 and coming from


high school having size>1000.
Ans: select count(*) from student where gpa > 3.4 AND sizeHS
> 1000;

12. Find how many students applied to ‘marine biology’.


Ans: select count(*) from apply where major='marine biology';
13. Find how many applications were rejected and accepted by
the colleges.
Ans: select decision, count(decision) from apply group by
decision;

14. Find how many students applied to a particular major.


(show count(sid) as No_of_applications).
Ans: select major, count(sid) as No_of_applications from apply
group by major;
15. Find number of applications received by a particular
college.
Ans: select cname, count(*) from apply group by cname;

16. Find number of applications received in a particular major


at a particular college.
Ans: select cname, major, count(*) from apply group by cname,
major;
17. Give the college name and major, where the number of
applications received are greater than or equal to 2.
Ans: select cname, major, count(*) from apply group by cname,
major having count(*) >= 2;

18. Give the name and no of applications of all those colleges


which receives applications from 3 or more students.
Ans: select cname, count(*) from apply group by cname having
count(DISTINCT sid) >= 3;

19. Give state and number of colleges of a state that has more
than 1 college.
Ans: select state, count(cname) from college group by state
having count(cname) > 1;

20. Find the name of students that are duplicate.


Ans: select sname from student group by sname having
count(sname) > 1;
21. Find how many applications are filed by each student.
[Hint: use a left join as we need information about all 12
students here. If they applied nowhere
Ans: select s.sname, count(a.sid) from student s left join apply a
on s.sid = a.sid group by s.sname order by s.sname;

22. Provide name of students that filed 3 or more applications.


Ans: select s.sname from student s left join apply a on s.sid =
a.sid group by s.sid, s.sname having count(a.sid) >= 3 order by
s.sid;

23. Provide name of student who have not applied to any


college.
Ans: select s.sname from student s left join apply a on s.sid =
a.sid group by s.sname, s.sid having count(a.sid) = 0 order by
s.sid;

24. Find maximum GPA, Average GPA, and minimum GPA


among applicants of each college. (i.e. say sID 123, 324 and 987
had applied to Berkley then compute and display max GPA
among these three)
Ans: select apply.cname, max(student.gpa) as max_gpa,
avg(student.gpa) as avg_gpa, min(student.gpa) as min_gpa from
apply join student on apply.sid = student.sid group by
apply.cname;

25. Find how many students have the 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(sid) as no_of_samegpa from student
group by gpa;
26. Find how many application of each major are rejected and
accepted.
Ans: select major, decision, count(*) from apply group by
decision, major;

27. Find out the acceptance rate for each college. (Acceptance
Rate is the percentage of the number application accepted w. r.
t. the number of application received)
Ans: select cname, count(case when decision='Y' then 1 END) /
count(decision) * 100 as acceptance_rate from apply group by
cname;

You might also like