狠狠撸

狠狠撸Share a Scribd company logo
#DBMS assignment 3(a)
#Author : Soumak Paul.
#Create table: DEPARTMENT
CREATE TABLE DEPARTMENT(
DeptCode varchar(4) NOT NULL,
DeptName varchar(40) NOT NULL,
HOD varchar(4),
PRIMARY KEY(DeptCode));
#Insert values into DEPARTMENT table.
INSERT INTO DEPARTMENT(DeptCode,DeptName,HOD)
VALUES('IT','Information Technology','F201');
INSERT INTO DEPARTMENT(DeptCode,DeptName,HOD)
VALUES('BIO','Bio Technology','F901');
INSERT INTO DEPARTMENT(DeptCode,DeptName,HOD)
VALUES('CSE','Computer Science and Engineering,'F101');
INSERT INTO DEPARTMENT(DeptCode,DeptName,HOD)
VALUES('NS','Natural Science','F506');
#Add a foreign key constraint in STUDENT against DeptCode column which
references department.
ALTER TABLE STUDENT
ADD FOREIGN KEY (DeptCode) REFERENCES DEPARTMENT(DeptCode);
#Create table: FACULTY
CREATE TABLE FACULTY(
FacultyCode varchar(4) NOT NULL,
FacultyName varchar(15) NOT NULL,
DateOfJoin date NOT NULL,
DeptCode varchar(4) NOT NULL,
PRIMARY KEY (FacultyCode));
#Insert values into FACULTY table.
INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode)
VALUES('F101','M. Sinha','2005-01-01','CSE');
INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode)
VALUES('F105','P. Sarkar','2019-02-01','CSE');
INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode)
VALUES('F201','S. Mazumder','2005-09-15','IT');
INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode)
VALUES('F301','S. Mondal','2018-08-01','CSE');
INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode)
VALUES('F401','D. Majumdar','2003-12-01','IT');
INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode)
VALUES('F506','N. Biswas','2013-12-31','NS');
INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode)
VALUES('F607','R. Paul','2007-04-10','BIO');
INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode)
VALUES('F704','S. Sarkar','2012-01-01','IT');
INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode)
VALUES('F808','K. Das','2010-06-15','IT');
INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode)
VALUES('F901','R. Roy','2017-06-15','BIO');
INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode)
VALUES('F902','R. Biswas','2018-06-15','BIO');
#Alter the table Faculty and add check constraint such that FacultyCode starts
with ‘F’
ALTER TABLE FACULTY
ADD CONSTRAINT FacultyCodeCheck CHECK (FacultyCode like 'F%');
#Alter the table Faculty and add check constraint such DeptCode is either
CSE,IT, BIO,NS
ALTER TABLE FACULTY
ADD CONSTRAINT DeptCodeCheck CHECK (DeptCode IN ('CSE','IT','NS','BIO'));
#Add constraint : DeptCode of Faculty is foreign key and references DeptCode
in Department.
ALTER TABLE FACULTY
ADD FOREIGN KEY (DeptCode) REFERENCES DEPARTMENT(DeptCode);
#Add Constraint: HOD of Department table is foreign key and references
FacultyCode of Faculty.
ALTER TABLE DEPARTMENT
ADD FOREIGN KEY (HOD) REFERENCES FACULTY(FacultyCode);
#Find the names of faculties of CSE Department.
SELECT FacultyName FROM FACULTY WHERE DeptCode = 'CSE';
#Find the number of faculties in the IT department
SELECT COUNT(*) FROM FACULTY WHERE DeptCode = 'IT';
#Find the number of faculties who joined in August?.
SELECT COUNT(*) AS 'Hired in August' FROM FACULTY
WHERE (MONTH(DateOfJoin) = 8);
#Show the names of the heads of departments with department name.
SELECT FACULTY.DeptCode AS 'DEPARTMENT NAME', FACULTY.FacultyName AS 'HOD NAME'
FROM FACULTY
INNER JOIN DEPARTMENT ON FACULTY.DeptCode = DEPARTMENT.DeptCode
GROUP BY DEPARTMENT.DeptCode
ORDER BY DEPARTMENT.DeptCode;
#Add an extra attribute to the faculty table - Salary Number(8,2)
ALTER TABLE FACULTY
ADD COLUMN SalaryNumber DECIMAL(8,2) AFTER DeptCode;
#Insert values into the corresponding field Salary Number(8,2) (Enter distinct
values).
UPDATE FACULTY SET SalaryNumber = '25000.00' WHERE FacultyCode = 'F101';
UPDATE FACULTY SET SalaryNumber = '15000.00' WHERE FacultyCode = 'F105';
UPDATE FACULTY SET SalaryNumber = '18000.00' WHERE FacultyCode = 'F201';
UPDATE FACULTY SET SalaryNumber = '16500.00' WHERE FacultyCode = 'F301';
UPDATE FACULTY SET SalaryNumber = '16000.00' WHERE FacultyCode = 'F401';
UPDATE FACULTY SET SalaryNumber = '18000.00' WHERE FacultyCode = 'F506';
UPDATE FACULTY SET SalaryNumber = '15000.00' WHERE FacultyCode = 'F607';
UPDATE FACULTY SET SalaryNumber = '11000.00' WHERE FacultyCode = 'F704';
UPDATE FACULTY SET SalaryNumber = '13000.00' WHERE FacultyCode = 'F808';
UPDATE FACULTY SET SalaryNumber = '20000.00' WHERE FacultyCode = 'F901';
UPDATE FACULTY SET SalaryNumber = '14000.00' WHERE FacultyCode = 'F902';
#Find the Department having more than one faculty.
SELECT DEPARTMENT.DeptCode
FROM FACULTY
INNER JOIN DEPARTMENT
ON FACULTY.DeptCode = DEPARTMENT.DeptCode
GROUP BY DEPARTMENT.DeptCode
HAVING COUNT(*) > 1;
#Find the name, department of the faculties who earn between 8000 and 12000.
SELECT FacultyName, DeptCode FROM FACULTY
WHERE (SalaryNumber >= 8000 AND SalaryNumber <= 12000);
#Find the name of the department with maximum faculties.
SELECT DeptName, COUNT(*) AS DEPTCOUNT FROM FACULTY
JOIN DEPARTMENT ON FACULTY.DeptCode = DEPARTMENT.DeptCode
GROUP BY DeptName
ORDER BY DEPTCOUNT DESC
LIMIT 1;
#Find the senior-most faculty.
SELECT * FROM FACULTY
ORDER BY DateOfJoin
LIMIT 1;
#Find the name of the faculty who has completed 5 years?.
SELECT FacultyName FROM FACULTY
WHERE (DATEDIFF(CURDATE(),DateOfJoin) > 1826);
Ad

Recommended

Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)
Achmad Solichin
?
Les18
Les18
Vijay Kumar
?
Les17
Les17
Vijay Kumar
?
rdbms practical record
rdbms practical record
Shivaraju KoilaKonda
?
Very simple queries of DBMS
Very simple queries of DBMS
mohit tripathi
?
DBMS Notes selection projection aggregate
DBMS Notes selection projection aggregate
Sreedhar Chowdam
?
4. DML.pdf
4. DML.pdf
Sunita Milind Dol
?
lab.123456789123456789123456789123456789
lab.123456789123456789123456789123456789
Ghh
?
Relational Database Managment System Lab - Group A
Relational Database Managment System Lab - Group A
Murugan146644
?
YASH DBMS PRACTICAL FILE DIGVIJAY COLLAGE .pdf
YASH DBMS PRACTICAL FILE DIGVIJAY COLLAGE .pdf
yash production
?
Md
Md
nanaJenglot
?
create_FinalDB.sql ---------------------------------------.docx
create_FinalDB.sql ---------------------------------------.docx
faithxdunce63732
?
MergeResult_2023_11_05_10_40_21.pptxoooo
MergeResult_2023_11_05_10_40_21.pptxoooo
Priyanka77088
?
DDl
DDl
Muhammad Zubair
?
Sql server query collection
Sql server query collection
Rabin Koirala
?
SQL Queries and Solutions (Database)
SQL Queries and Solutions (Database)
SM. Aurnob
?
SQL Practice Question set
SQL Practice Question set
Mohd Tousif
?
5. Basic Structure of SQL Queries.pdf
5. Basic Structure of SQL Queries.pdf
Sunita Milind Dol
?
On SQL Managment studioThis lab is all about database normalizatio.pdf
On SQL Managment studioThis lab is all about database normalizatio.pdf
infomalad
?
Relational DB Course
Relational DB Course
Sunny U Okoro
?
Sql (Introduction to Structured Query language)
Sql (Introduction to Structured Query language)
Mohd Tousif
?
Here is the company database for the problem--commen.pdf
Here is the company database for the problem--commen.pdf
fazilfootsteps
?
Sql file (1)
Sql file (1)
rajkumari873
?
DBMS ASSIGNMENT questions list for graduation .pdf
DBMS ASSIGNMENT questions list for graduation .pdf
StudyWithBarkha
?
Tallerpractica
Tallerpractica
guest4b949be
?
Tallerpractica
Tallerpractica
brayanpalomino
?
Tallerpractica
Tallerpractica
guest4b949be
?
Taller 4
Taller 4
blaze0002
?
Revolutionizing Environmental Compliance with AI.pdf
Revolutionizing Environmental Compliance with AI.pdf
Dorian F Corliss
?
TECHNOLOGY LIVELIHOOD EDUCATIONLESSON EXEMPLAR
TECHNOLOGY LIVELIHOOD EDUCATIONLESSON EXEMPLAR
AnnMargrettDuka
?

More Related Content

Similar to Dbms assignment 3(a) (1) (20)

Relational Database Managment System Lab - Group A
Relational Database Managment System Lab - Group A
Murugan146644
?
YASH DBMS PRACTICAL FILE DIGVIJAY COLLAGE .pdf
YASH DBMS PRACTICAL FILE DIGVIJAY COLLAGE .pdf
yash production
?
Md
Md
nanaJenglot
?
create_FinalDB.sql ---------------------------------------.docx
create_FinalDB.sql ---------------------------------------.docx
faithxdunce63732
?
MergeResult_2023_11_05_10_40_21.pptxoooo
MergeResult_2023_11_05_10_40_21.pptxoooo
Priyanka77088
?
DDl
DDl
Muhammad Zubair
?
Sql server query collection
Sql server query collection
Rabin Koirala
?
SQL Queries and Solutions (Database)
SQL Queries and Solutions (Database)
SM. Aurnob
?
SQL Practice Question set
SQL Practice Question set
Mohd Tousif
?
5. Basic Structure of SQL Queries.pdf
5. Basic Structure of SQL Queries.pdf
Sunita Milind Dol
?
On SQL Managment studioThis lab is all about database normalizatio.pdf
On SQL Managment studioThis lab is all about database normalizatio.pdf
infomalad
?
Relational DB Course
Relational DB Course
Sunny U Okoro
?
Sql (Introduction to Structured Query language)
Sql (Introduction to Structured Query language)
Mohd Tousif
?
Here is the company database for the problem--commen.pdf
Here is the company database for the problem--commen.pdf
fazilfootsteps
?
Sql file (1)
Sql file (1)
rajkumari873
?
DBMS ASSIGNMENT questions list for graduation .pdf
DBMS ASSIGNMENT questions list for graduation .pdf
StudyWithBarkha
?
Tallerpractica
Tallerpractica
guest4b949be
?
Tallerpractica
Tallerpractica
brayanpalomino
?
Tallerpractica
Tallerpractica
guest4b949be
?
Taller 4
Taller 4
blaze0002
?
Relational Database Managment System Lab - Group A
Relational Database Managment System Lab - Group A
Murugan146644
?
YASH DBMS PRACTICAL FILE DIGVIJAY COLLAGE .pdf
YASH DBMS PRACTICAL FILE DIGVIJAY COLLAGE .pdf
yash production
?
create_FinalDB.sql ---------------------------------------.docx
create_FinalDB.sql ---------------------------------------.docx
faithxdunce63732
?
MergeResult_2023_11_05_10_40_21.pptxoooo
MergeResult_2023_11_05_10_40_21.pptxoooo
Priyanka77088
?
Sql server query collection
Sql server query collection
Rabin Koirala
?
SQL Queries and Solutions (Database)
SQL Queries and Solutions (Database)
SM. Aurnob
?
SQL Practice Question set
SQL Practice Question set
Mohd Tousif
?
5. Basic Structure of SQL Queries.pdf
5. Basic Structure of SQL Queries.pdf
Sunita Milind Dol
?
On SQL Managment studioThis lab is all about database normalizatio.pdf
On SQL Managment studioThis lab is all about database normalizatio.pdf
infomalad
?
Sql (Introduction to Structured Query language)
Sql (Introduction to Structured Query language)
Mohd Tousif
?
Here is the company database for the problem--commen.pdf
Here is the company database for the problem--commen.pdf
fazilfootsteps
?
DBMS ASSIGNMENT questions list for graduation .pdf
DBMS ASSIGNMENT questions list for graduation .pdf
StudyWithBarkha
?

Recently uploaded (20)

Revolutionizing Environmental Compliance with AI.pdf
Revolutionizing Environmental Compliance with AI.pdf
Dorian F Corliss
?
TECHNOLOGY LIVELIHOOD EDUCATIONLESSON EXEMPLAR
TECHNOLOGY LIVELIHOOD EDUCATIONLESSON EXEMPLAR
AnnMargrettDuka
?
Ruchi Bhatia HRGurukul - The Roads less travelled
Ruchi Bhatia HRGurukul - The Roads less travelled
Ruchi Bhatia
?
Biography and career history of Dr. Gabriel Carabello
Biography and career history of Dr. Gabriel Carabello
Dr. Gabriel Carabello
?
Power BI Jobs in Jaipur Your Gateway to Data Analytics Careers in Rajasthan.pptx
Power BI Jobs in Jaipur Your Gateway to Data Analytics Careers in Rajasthan.pptx
vinay salarite
?
Cost_Effective_Multi_Source_Energy_Harvesting_System1 final 5.pptx
Cost_Effective_Multi_Source_Energy_Harvesting_System1 final 5.pptx
AnishNaskar4
?
Presentation about the current products.pptx
Presentation about the current products.pptx
ikrammustafa51
?
最新版意大利拉奎拉大学毕业证(础蚕鲍滨尝础毕业证书)原版定制
最新版意大利拉奎拉大学毕业证(础蚕鲍滨尝础毕业证书)原版定制
taqyea
?
Rolph Balgobin - The Different Types of Entrepreneur
Rolph Balgobin - The Different Types of Entrepreneur
Rolph Balgobin
?
Gives a structured overview of the skills measured in the DP-700 exam
Gives a structured overview of the skills measured in the DP-700 exam
thehulk1299
?
PRESENTATION general mathematicsppt.pptx
PRESENTATION general mathematicsppt.pptx
DharylBallarta
?
Pakistan Economy presentation pakistan.pptx
Pakistan Economy presentation pakistan.pptx
ikrammustafa51
?
Corporate Philanthropy’s Impact on Communities.pdf
Corporate Philanthropy’s Impact on Communities.pdf
Hassan Dakhlallah
?
Quarter 3 Program Implementation Review and Performance Assessment
Quarter 3 Program Implementation Review and Performance Assessment
LaMariaAngelicaPunay
?
Yellow and Purple Doodle Startup Pitch Deck Presentation.pdf.pdf
Yellow and Purple Doodle Startup Pitch Deck Presentation.pdf.pdf
kharadeshreya2210
?
IISc-CDS-v2xxxxxxxxxxxxxcxxxxxx (1).potx
IISc-CDS-v2xxxxxxxxxxxxxcxxxxxx (1).potx
rnkaushal2
?
最新版美国埃默里大学毕业证(贰尘辞谤测毕业证书)原版定制
最新版美国埃默里大学毕业证(贰尘辞谤测毕业证书)原版定制
Taqyea
?
最新版美国休斯顿大学毕业证(鲍贬毕业证书)原版定制
最新版美国休斯顿大学毕业证(鲍贬毕业证书)原版定制
Taqyea
?
8queensproblemusingbacktracking-120903114053-phpapp01.pptx
8queensproblemusingbacktracking-120903114053-phpapp01.pptx
halderdhrubo6
?
Current Affairs for Prelims (Schemes) 2024 (1).pptx
Current Affairs for Prelims (Schemes) 2024 (1).pptx
malavikasprinklr
?
Revolutionizing Environmental Compliance with AI.pdf
Revolutionizing Environmental Compliance with AI.pdf
Dorian F Corliss
?
TECHNOLOGY LIVELIHOOD EDUCATIONLESSON EXEMPLAR
TECHNOLOGY LIVELIHOOD EDUCATIONLESSON EXEMPLAR
AnnMargrettDuka
?
Ruchi Bhatia HRGurukul - The Roads less travelled
Ruchi Bhatia HRGurukul - The Roads less travelled
Ruchi Bhatia
?
Biography and career history of Dr. Gabriel Carabello
Biography and career history of Dr. Gabriel Carabello
Dr. Gabriel Carabello
?
Power BI Jobs in Jaipur Your Gateway to Data Analytics Careers in Rajasthan.pptx
Power BI Jobs in Jaipur Your Gateway to Data Analytics Careers in Rajasthan.pptx
vinay salarite
?
Cost_Effective_Multi_Source_Energy_Harvesting_System1 final 5.pptx
Cost_Effective_Multi_Source_Energy_Harvesting_System1 final 5.pptx
AnishNaskar4
?
Presentation about the current products.pptx
Presentation about the current products.pptx
ikrammustafa51
?
最新版意大利拉奎拉大学毕业证(础蚕鲍滨尝础毕业证书)原版定制
最新版意大利拉奎拉大学毕业证(础蚕鲍滨尝础毕业证书)原版定制
taqyea
?
Rolph Balgobin - The Different Types of Entrepreneur
Rolph Balgobin - The Different Types of Entrepreneur
Rolph Balgobin
?
Gives a structured overview of the skills measured in the DP-700 exam
Gives a structured overview of the skills measured in the DP-700 exam
thehulk1299
?
PRESENTATION general mathematicsppt.pptx
PRESENTATION general mathematicsppt.pptx
DharylBallarta
?
Pakistan Economy presentation pakistan.pptx
Pakistan Economy presentation pakistan.pptx
ikrammustafa51
?
Corporate Philanthropy’s Impact on Communities.pdf
Corporate Philanthropy’s Impact on Communities.pdf
Hassan Dakhlallah
?
Quarter 3 Program Implementation Review and Performance Assessment
Quarter 3 Program Implementation Review and Performance Assessment
LaMariaAngelicaPunay
?
Yellow and Purple Doodle Startup Pitch Deck Presentation.pdf.pdf
Yellow and Purple Doodle Startup Pitch Deck Presentation.pdf.pdf
kharadeshreya2210
?
IISc-CDS-v2xxxxxxxxxxxxxcxxxxxx (1).potx
IISc-CDS-v2xxxxxxxxxxxxxcxxxxxx (1).potx
rnkaushal2
?
最新版美国埃默里大学毕业证(贰尘辞谤测毕业证书)原版定制
最新版美国埃默里大学毕业证(贰尘辞谤测毕业证书)原版定制
Taqyea
?
最新版美国休斯顿大学毕业证(鲍贬毕业证书)原版定制
最新版美国休斯顿大学毕业证(鲍贬毕业证书)原版定制
Taqyea
?
8queensproblemusingbacktracking-120903114053-phpapp01.pptx
8queensproblemusingbacktracking-120903114053-phpapp01.pptx
halderdhrubo6
?
Current Affairs for Prelims (Schemes) 2024 (1).pptx
Current Affairs for Prelims (Schemes) 2024 (1).pptx
malavikasprinklr
?
Ad

Dbms assignment 3(a) (1)

  • 1. #DBMS assignment 3(a) #Author : Soumak Paul. #Create table: DEPARTMENT CREATE TABLE DEPARTMENT( DeptCode varchar(4) NOT NULL, DeptName varchar(40) NOT NULL, HOD varchar(4), PRIMARY KEY(DeptCode)); #Insert values into DEPARTMENT table. INSERT INTO DEPARTMENT(DeptCode,DeptName,HOD) VALUES('IT','Information Technology','F201'); INSERT INTO DEPARTMENT(DeptCode,DeptName,HOD) VALUES('BIO','Bio Technology','F901'); INSERT INTO DEPARTMENT(DeptCode,DeptName,HOD) VALUES('CSE','Computer Science and Engineering,'F101'); INSERT INTO DEPARTMENT(DeptCode,DeptName,HOD) VALUES('NS','Natural Science','F506'); #Add a foreign key constraint in STUDENT against DeptCode column which references department. ALTER TABLE STUDENT ADD FOREIGN KEY (DeptCode) REFERENCES DEPARTMENT(DeptCode); #Create table: FACULTY CREATE TABLE FACULTY( FacultyCode varchar(4) NOT NULL, FacultyName varchar(15) NOT NULL, DateOfJoin date NOT NULL, DeptCode varchar(4) NOT NULL, PRIMARY KEY (FacultyCode)); #Insert values into FACULTY table. INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode) VALUES('F101','M. Sinha','2005-01-01','CSE'); INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode) VALUES('F105','P. Sarkar','2019-02-01','CSE'); INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode) VALUES('F201','S. Mazumder','2005-09-15','IT'); INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode) VALUES('F301','S. Mondal','2018-08-01','CSE'); INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode) VALUES('F401','D. Majumdar','2003-12-01','IT'); INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode) VALUES('F506','N. Biswas','2013-12-31','NS'); INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode)
  • 2. VALUES('F607','R. Paul','2007-04-10','BIO'); INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode) VALUES('F704','S. Sarkar','2012-01-01','IT'); INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode) VALUES('F808','K. Das','2010-06-15','IT'); INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode) VALUES('F901','R. Roy','2017-06-15','BIO'); INSERT INTO FACULTY(FacultyCode,FacultyName,DateOfJoin,DeptCode) VALUES('F902','R. Biswas','2018-06-15','BIO'); #Alter the table Faculty and add check constraint such that FacultyCode starts with ‘F’ ALTER TABLE FACULTY ADD CONSTRAINT FacultyCodeCheck CHECK (FacultyCode like 'F%'); #Alter the table Faculty and add check constraint such DeptCode is either CSE,IT, BIO,NS ALTER TABLE FACULTY ADD CONSTRAINT DeptCodeCheck CHECK (DeptCode IN ('CSE','IT','NS','BIO')); #Add constraint : DeptCode of Faculty is foreign key and references DeptCode in Department. ALTER TABLE FACULTY ADD FOREIGN KEY (DeptCode) REFERENCES DEPARTMENT(DeptCode); #Add Constraint: HOD of Department table is foreign key and references FacultyCode of Faculty. ALTER TABLE DEPARTMENT ADD FOREIGN KEY (HOD) REFERENCES FACULTY(FacultyCode); #Find the names of faculties of CSE Department. SELECT FacultyName FROM FACULTY WHERE DeptCode = 'CSE'; #Find the number of faculties in the IT department SELECT COUNT(*) FROM FACULTY WHERE DeptCode = 'IT'; #Find the number of faculties who joined in August?. SELECT COUNT(*) AS 'Hired in August' FROM FACULTY WHERE (MONTH(DateOfJoin) = 8); #Show the names of the heads of departments with department name. SELECT FACULTY.DeptCode AS 'DEPARTMENT NAME', FACULTY.FacultyName AS 'HOD NAME' FROM FACULTY INNER JOIN DEPARTMENT ON FACULTY.DeptCode = DEPARTMENT.DeptCode GROUP BY DEPARTMENT.DeptCode ORDER BY DEPARTMENT.DeptCode;
  • 3. #Add an extra attribute to the faculty table - Salary Number(8,2) ALTER TABLE FACULTY ADD COLUMN SalaryNumber DECIMAL(8,2) AFTER DeptCode; #Insert values into the corresponding field Salary Number(8,2) (Enter distinct values). UPDATE FACULTY SET SalaryNumber = '25000.00' WHERE FacultyCode = 'F101'; UPDATE FACULTY SET SalaryNumber = '15000.00' WHERE FacultyCode = 'F105'; UPDATE FACULTY SET SalaryNumber = '18000.00' WHERE FacultyCode = 'F201'; UPDATE FACULTY SET SalaryNumber = '16500.00' WHERE FacultyCode = 'F301'; UPDATE FACULTY SET SalaryNumber = '16000.00' WHERE FacultyCode = 'F401'; UPDATE FACULTY SET SalaryNumber = '18000.00' WHERE FacultyCode = 'F506'; UPDATE FACULTY SET SalaryNumber = '15000.00' WHERE FacultyCode = 'F607'; UPDATE FACULTY SET SalaryNumber = '11000.00' WHERE FacultyCode = 'F704'; UPDATE FACULTY SET SalaryNumber = '13000.00' WHERE FacultyCode = 'F808'; UPDATE FACULTY SET SalaryNumber = '20000.00' WHERE FacultyCode = 'F901'; UPDATE FACULTY SET SalaryNumber = '14000.00' WHERE FacultyCode = 'F902'; #Find the Department having more than one faculty. SELECT DEPARTMENT.DeptCode FROM FACULTY INNER JOIN DEPARTMENT ON FACULTY.DeptCode = DEPARTMENT.DeptCode GROUP BY DEPARTMENT.DeptCode HAVING COUNT(*) > 1; #Find the name, department of the faculties who earn between 8000 and 12000. SELECT FacultyName, DeptCode FROM FACULTY WHERE (SalaryNumber >= 8000 AND SalaryNumber <= 12000); #Find the name of the department with maximum faculties. SELECT DeptName, COUNT(*) AS DEPTCOUNT FROM FACULTY JOIN DEPARTMENT ON FACULTY.DeptCode = DEPARTMENT.DeptCode GROUP BY DeptName ORDER BY DEPTCOUNT DESC LIMIT 1; #Find the senior-most faculty. SELECT * FROM FACULTY ORDER BY DateOfJoin LIMIT 1; #Find the name of the faculty who has completed 5 years?. SELECT FacultyName FROM FACULTY WHERE (DATEDIFF(CURDATE(),DateOfJoin) > 1826);