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

Dbms Lab Final A

This document is a lab final term examination for a database management system course. It provides instructions for students to create a database called "Final Term" and populate a table called "EmployeeInfo" with sample data. It then lists 10 questions for students to write SQL queries to retrieve and analyze data from the EmployeeInfo table. The questions include counting and filtering records, sorting results, and retrieving minimum, maximum, and duplicate records. Students are reminded that academic honesty is important and not to copy from outside sources on the exam.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views

Dbms Lab Final A

This document is a lab final term examination for a database management system course. It provides instructions for students to create a database called "Final Term" and populate a table called "EmployeeInfo" with sample data. It then lists 10 questions for students to write SQL queries to retrieve and analyze data from the EmployeeInfo table. The questions include counting and filtering records, sorting results, and retrieving minimum, maximum, and duplicate records. Students are reminded that academic honesty is important and not to copy from outside sources on the exam.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Department of Electrical & Computer Engineering

Air University Islamabad


Lab Final Term Examination : Fall 2022

Student Name: __ASHAR HUSSNAIN_____________ Student


ID: ____________

Subject: Database Management System Lab Total Points: 150

Course Code: CE Time: 45 mins

Class: : BCE-F-19-A Due Date: Thurs Dec 22th, 2022

SPECIAL INSTRUCTIONS:
1. This is open book, open manual examination.
2. Create a new database named Final Term and run all the queries in it, solve the requirements in
the question.
3. Document all your work.
4. Any assumption made must be clearly stated.

Important Reminder on Academic Honesty

Using unauthorized information or notes on the exam, peaking at others work, or alter graded
exams to claim more credit are severe violations of academic honesty. Detected cases will face
serious repercussions.
*Do not copy from any source.

Best of Luck 
P.T.O
Total Points: 130
Part A: Create a Table EmployeeInfo and populate that according to this given table.
EmpID EmpFname EmpLname Department Project Address DOB Gender
1 Sanjay Mehra HR P1 Hyderabad(HYD) 01/12/1976 M
2 Ananya Mishra Admin P2 Delhi(DEL) 02/05/1968 F
3 Rohan Diwan Account P3 Mumbai(BOM) 01/01/1980 M
4 Sonia Kulkarni HR P1 Hyderabad(HYD) 02/05/1992 F
5 Ankit Kapoor Admin P2 Delhi(DEL) 03/07/1994 M

Table code:
create database labfinalashar22

create table employinfoo(


emplid int,
emplFName varchar(30),
emplLName varchar(30),
department varchar(40),
project varchar (30),
adderss varchar (30),
DOB char (40),
gender varchar(60),

);

INSERT into employinfoo


values
(1,'sanjay','mehra','HR','P1','HYDERABAD(HYD)','01/12/1976','M'),
(2,'ananya','mishra','admin','P2','delhi(DEL)','02/05/1968','F'),
(3,'Rohan','diwan','account','P3','MUmbai(bom) ','01/01/1980','M'),
(4,'sonia','kulkarni','HR','P1','HYDERABAD(HYD)','02/05/1992','F'),
(5,'ANKIT','kapoor','admin','P2','delhi(DEL)','03/07/1994','M')

Best of Luck 
P.T.O
Best of Luck 
P.T.O
Q1:  Write a query to fetch the number of employees working in the department
‘HR’.
select * from employinfoo
SELECT * FROM employinfoo
WHERE department='HR'

Q2: Write a query find number of employees whose DOB is between 02/05/1970 to
31/12/1975 and are grouped according to gender.
SELECT * FROM employinfoo
WHERE DOB between '02/05/1970' and '31/12/1975'

Best of Luck 
P.T.O
Q3: Write a query to fetch details of all employees excluding the employees with
first names, “Sanjay” and “Sonia” from the EmployeeInfo table.
SELECT * FROM employinfoo
WHERE emplFName NOT LIKE '[sanjay,sonia]%'

Best of Luck 
P.T.O
Q4: Write a query to fetch the department-wise count of employees sorted by
department’s count in ascending order.
SELECT department
FROM employinfoo
ORDER BY department ASC

Q5: Write a query to retrieve duplicate records from a table.

Q6: Write a query to retrieve the last 3 records from the EmployeeInfo table.
select * from employinfoo
SELECT count (*) as department FROM employinfoo

Best of Luck 
P.T.O
Q7: Write a query to retrieve Departments who have less than 2 employees
working in it.

Q8: Write a query to display the first record from the EmployeeInfo table.+

Q9: Write a query to display the the last record from the EmployeeInfo table.
SELECT * FROM employinfoo
WHERE emplFName LIKE '[ANKIT]%'

Best of Luck 
P.T.O
Q10: Write a query to fetch the department-wise count of employees sorted by
department’s count in ascending order.

SELECT department
FROM employinfoo
ORDER BY department DESC

Best of Luck 
P.T.O
Best of Luck 
P.T.O

You might also like