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

Assignment 05

The document contains 25 SQL queries that analyze data from tables containing student, college, and application information, including queries to select, group, count, insert, update, delete data based on conditions like name, major, GPA comparisons and set operations like union, intersect, minus. Many queries join the student, apply, and college tables on fields like sid, cname, and state to retrieve related data between the tables.

Uploaded by

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

Assignment 05

The document contains 25 SQL queries that analyze data from tables containing student, college, and application information, including queries to select, group, count, insert, update, delete data based on conditions like name, major, GPA comparisons and set operations like union, intersect, minus. Many queries join the student, apply, and college tables on fields like sid, cname, and state to retrieve related data between the tables.

Uploaded by

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

ASSIGNMENT-05

1.select sid,sname from student where sid in(select sid from apply where
major='CS');
2. select sid,sname from student where sizeHS in(select sizeHS from student
where sname='Jay');
3. select sid,sname from student where sizeHS in(select sizeHS from student
where sname='Jay')and sname not in('Jay');
4. select sid,sname,gpa from student where gpa not in(select gpa from student
where sname='Irene');
5. select cname from apply where sid in(select sid from student where
snamelike'J%');
6. select distinct major from apply where sid in(select sid from student
where sname='Irene');
7. select distinct sid,major from apply where major in(select major from
apply where sid in (select sid from student s1 where sname='Irene'));
8. select distinct sid,major from apply where major in(select major from
apply where sid in (select sid from student where sname='Irene'))and sid not
in(select sid from student where sname='Irene');
9. select count(distinct cname) from apply where sid in(select sid from
student where sname='Jay');
10. select sid from apply where cname in(select cname from apply where sid
in(select sid from student where sname='Jay'));
11. select * from student where sid in(select sid from apply where major='CS'
minus select sid from apply where major='EE');

12. select cname from college c1 where exists(select state from college c2
where c1.state=c2.state and c1.cname!=c2.cname);
13. select cname,enrollment from college c1 where not exists(select enrollment
from college c2 where c1.enrollment<c2.enrollment);
14. select sname from student s1 where not exists(select sname from student s2
where s1.gpa>s2.gpa);
15. select major, count(sid) from apply group by major having
count(sid)=(select max(count(sid)) from apply group by major);
16. select sid,sizehs,sname from student where sizehs!=(select min(sizehs)
from student);
17. select sname,sid from student where not exists (select distinct cname
from apply where sid=987 minus select distinct cname from apply where
sid=student.sid);
18. insert into Apply select s1.sID, 'Berkeley', 'CSE', 'Y' from student
s1where s1.sID
IN (select s.sID from student s MINUS select a.sID from apply a where a.cName =
'Berkeley'); select cname from college c where not exists((select sid from
student s)minus (select sid from apply a where a.cname=c.cname));
19. select sid from student minus(select distinct sid from apply where
cname='Stanford');
20. (select sid from apply where cname='Stanford')intersect(select sid from
apply where cname='Berkeley');
21. select sname from student union select cname from college;
22. create table ApplicationInfo( sid int,sname
varchar2(10),number_of_applications number(2));
insert into applicationinfo select s.sid,s.sname,nvl(a.no_of_application,0)from
((select sid,sname from student) s left outer join(select sid,count(*) as
no_of_application from apply group by sid) a on s.sid=a.sid); select * from
applicationinfo;
23. create table ApplicationData as ( select distinct sid,cname,state from
apply natural join college );
24. update apply set decision='N' where cname='Stanford' and sid in ((select
sid from apply where cname='Stanford')intersect(select sid from apply where
cname='Berkeley'));
25. delete from apply where cname in(select cname from college where state =
'NY');

You might also like