Dbms Lab Final A
Dbms Lab Final A
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.
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
);
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
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