Documente Academic
Documente Profesional
Documente Cultură
1.
Data Type
Varchar2
Varchar2
Varchar2
Size
4
15
4
Constraints
Not null, Primary key
Not null
Foreign key references FacultyCode of table
FACULTY
Data Type
Varchar2
Varchar2
Date
Varchar2
Size
4
15
Constraints
Not null, Primary key, Starts with F
Not null
Not null
Must be either CSE,IT, CA, CHEM, MTHS,
PHYS, HUM, BBA
FACULTY
Column Name
FacultyCode
FacultyName
DateOfJoin
DeptCode
FACULTYNAME
--------------M.Mohanto
S.M.Roy
M.Dasgupta
5. Find the number of faculties in the Computer application department
Select FacultyName from faculty41
where DeptCode='CA';
FACULTYNAME
--------------K.K.Patil
6. Show the names of the heads of departments with department name.
Select FacultyName,DeptName from faculty41,DEPARTMENT41
where DEPARTMENT41.HOD=faculty41.FacultyCode;
FACULTYNAME DEPTNAME
--------------- --------------S.M.Roy
Computer Sci
S.Chakraborty
InfoTech
K.K.Patil
Comp Appli.
S.C.Kareem
Chemistry
P.Mukherjee
MAthematics
K.Mondal
Physics
P.Roy
Humanities
M.Singh
Busi. Admns
6) Find the names of 3rd year CSE students whose date of birth is earlier than 15th August 1981.
Update faculty41
set salary=7000 where FacultyCode='F02';
Update faculty41
set salary=25000 where FacultyCode='F03';
Update faculty41
set salary=10000 where FacultyCode='F04';
Update faculty41
set salary=10000.50 where FacultyCode='F05';
Update faculty41
set salary=12500 where FacultyCode='F06';
Update faculty41
set salary=15050 where FacultyCode='F07';
Update faculty41
set salary=11200.75 where FacultyCode='F08';
Update faculty41
set salary=12000 where FacultyCode='F09';
Update faculty41
set salary=11000 where FacultyCode='F10';
Update faculty41
set salary=5000 where FacultyCode='F11';
11 Find the name and salary of the faculty who earn more than 8000.
select FacultyName,salary from faculty41
where salary>=8000;
FACULTYNAME
--------------- ---------S.Chakraborty
S.M.Roy
K.K.Patil
S.C.Kareem
P.Roy
M.Singh
P.Mukherjee
K.Mondal
B.Das
SALARY
15000
25000
10000
10000.5
12500
15050
11200.75
12000
11000
12 Find the name, department of the faculties who earn between 8000 and 12000.
select FacultyName,DeptCode from faculty41
where salary between 8000 and 12000;
FACULTYNAME
--------------- ----
DEPT
K.K.Patil
S.C.Kareem
P.Mukherjee
K.Mondal
B.Das
CA
CHEM
MTHS
PHYS
IT
Assignment 4
1.
Data Type
Varchar2
Varchar2
Varchar2
Size
4
15
4
Constraints
Not null, Primary key
Not null
Foreign key references FacultyCode of table
FACULTY
values('CA31','PPL','F04');
1) Find the number of students in each department with their department name.
update faculty41
set salary=salary+500;
4
Find the names of students and faculties whose name start with S.
S.Chakraborty
B.Das
7
update subject41
set department='CSE',year='1' where faculty='F11';
update subject41
set department='IT',year='2' where faculty='F01';
update subject41
set department='CA',year='2' where faculty='F04';
update subject41
set department='CHEM',year='1' where faculty='F05';
update subject41
set department='HUM',year='3' where faculty='F06';
update subject41
set department='BBA',year='3' where faculty='F07';
update subject41
set department='MTHS',year='1' where faculty='F08';
update subject41
set department='PHYS',year='2' where faculty='F09';
DEPA
IT
2
HUM
3
BBA
3
PHYS 2
CA
2
CHEM 1
CSE
1
MTHS 1
8 rows selected.
10) Find the names of faculties who earn more than the average of all faculties.
SALARY
25500
15550
15) Find the names of faculties who are not the HODs of any department.
NESTED QUERIES:
create view countfaculty41_view as(select DeptCode, count(FacultyCode) as S from faculty41 group by
DeptCode);
SQL> select * from countfaculty41_view;
DEPT
S
---- ---------BBA
1
CA
1
CHEM
1
CSE
3
HUM
1
IT
2
MTHS
1
PHYS
1
8 rows selected.
ANS:
select FacultyName from faculty41
where DeptCode in (select DeptCode from countfaculty41_view where S in (select max(S) from
countfaculty41_view));
FACULTYNAME
--------------M.Mohanto
S.M.Roy
M.Dasgupta