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

Exp3 DBMS Lab

Uploaded by

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

Exp3 DBMS Lab

Uploaded by

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

NAME: Piyush Kumar

ROLL NO: 14

BRANCH: BTECH

SECTION: CF (CSF)

YEAR: 1st

SEMESTER: 2nd

SUBJECT: Database Management System Lab


Practical Assignment 3
Write the SQL queries to implement Set Operations and Joins.

1. Produce a combine table in which each student is combine with


every other application.
mysql> select * from student cross join apply;
2. Give student ID, name, GPA and name of college and major each
student applied to.
mysql> select student.SID, student.sname, student.GPA,
apply.cname, apply.major from student cross join apply where
student.sid=apply.sid;

3. Find detail of applications who applied to California state.


mysql> select a.sid,a.cname,a.major, a.decision from apply a inner
join college c on a.cname=c.cname where c.state='CA';

4. IDs, name, GPA of students and name of college with GPA >3.7
applying to Stanford.
mysql> select student.sid, student.sname, student.gpa,
apply.cname from student join apply on student.sid = apply.sid join
college on apply.cname = college.cname where college.cname =
'Stanford' and student.gpa > 3.7;
5. Find detail of student who apply to CS major and their application
are rejected.
mysql> select s.sid as student_id, s.sname as student_name, s.gpa,
a.cname as college_name, a.major, a.decision from student s inner
join apply a on s.sid = a.sid where a.major = 'CS' and a.decision =
'N';

6. Find detail of student and application who applied to colleges at


New York.
mysql> select s.sid as student_id, s.sname as student_name, s.gpa,
a.cname as college_name, a.major, a.decision from student s inner
join apply a on s.sid = a.sid inner join college c on a.cname =
c.cname where c.state = 'NY';

7. Find detail of student who have not applied to any of college.


mysql> select student.sid, student.sname from student left join
apply on student.sid = apply.sid where apply.sid is null;

8. Find college where no student has applied.


mysql> select college.cname from college left join apply on
college.cname= apply.cname where apply.sid is null;
9. Find sID who have only one application.
mysql> select sid from apply group by sid having count(*) = 1;

10. Find name and GPA of applicants who apply to any college
whose enrollment is not more than 25000.
mysql> select s.sname as student_name, s.gpa from student s inner
join apply a on s.sid = a.sid inner join college c on a.cname =
c.cname where c.enrollment <= 25000;

11. Find pair of students (sID) having same GPA. (each pair should
occur just once in result) 4
mysql> select distinct s1.sid as student1_id, s2.sid as student2_id
from student s1 inner join student s2 on s1.sid < s2.sid and s1.gpa =
s2.gpa;

You might also like