Student DB
Student DB
1. list all the student details studying in fourth semester ‘c’ section.
2. compute the total number of male and female students in each semester and in each
section.
4. calculate the finalia (average of best two test marks) and update the corresponding
table for all students.
give these details only for 8th semester a, b, and c section students.
ddl commands:
dml statements:
insert into iamarks (usn, subcode, ssid, test1, test2, test3) values ('4pm13cs091','10cs81','cse8c', 15, 16,
18);
insert into iamarks (usn, subcode, ssid, test1, test2, test3) values ('4pm13cs091','10cs82','cse8c', 12, 19,
14);
insert into iamarks (usn, subcode, ssid, test1, test2, test3) values ('4pm13cs091','10cs83','cse8c', 19, 15,
20);
insert into iamarks (usn, subcode, ssid, test1, test2, test3) values ('4pm13cs091','10cs84','cse8c', 20, 16,
19);
insert into iamarks (usn, subcode, ssid, test1, test2, test3) values ('4pm13cs091','10cs85','cse8c', 15, 15,
12);
usn ssid
4pm13cs020 cse8a
4pm13cs062 cse8a
4pm13cs066 cse8b
4pm13cs091 cse8c
4pm14cs010 cse7a
4pm14cs025 cse7a
4pm14cs032 cse7a
4pm15cs011 cse4a
4pm15cs029 cse4a
4pm15cs045 cse4b
4pm16cs045 cse3a
4pm16cs088 cse3b
4pm16cs122 cse3c
4pm13cs091 cse4c
ssid
sem sec
cse8a a
8
cse8b b
8
cse8c c
8
cse7a a
7
cse7b b
7
cse7c c
7
cse6a a
6
cse6b b
6
cse6c c
6
cse5a a
5
cse5b b
5
cse5c c
5
cse4a a
4
cse4b b
4
cse4c c
4
cse3a a
3
cse3b b
3
cse3c c
3
cse2a a
2
cse2b b
2
cse2c c
2
cse1a a
1
cse1b b
1
cse1c c
1
1. list all the student details studying in fourth semester ‘c’ section.
select *
from student s,semsec ss,class c
where s.usn=c.usn and ss.ssid=c.ssid and sem=4 and sec='c';
or
select *
from student natural join semsec natural join class
where sem=4 and sec='c';
2. compute the total number of male and female students in each semester and in each
section.
select *
from (select ssid,sec,count(gender) female_students
from student natural join class natural join semsec
where gender='f' group by ssid,sec) q1
left outer join
(select ssid,sec,count(gender) male_students
from student natural join class natural join semsec
where gender='m' group by ssid,sec) q2
on q1.ssid=q2.ssid and q1.sec=q2.sec;
4. calculate the finalia (average of best two test marks) and update the corresponding
table for all students.
update iamarks
set finalia= (case when test1>=test2 and test2>=test3 then (test1+test2)/2
when test2>=test1 and test3>=test2 then (test2+test3)/2
when test1>=test3 and test2>=test3 then (test1+test2)/2
else (test1+test3)/2
or
give these details only for 8th semester a, b, and c section students.
select usn, sname, finalia,(case when finalia between 17 and 20 then 'outstanding'
when finalia between 12 and 16 then 'average'
when finalia between 0 and 11 then 'weak'
else 'na'
end) as category
from iamarks natural join student natural join class natural join semsec
where sem=8 and sec in ('a','b','c');