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

Final DBMS File.word-1

The document outlines the vision and mission of the School of Computer Science and Applications, aiming to provide high-quality education and ethical empowerment through innovative technology. It includes a detailed index of practical SQL queries related to employee and customer data management, showcasing various database operations. Each query is accompanied by a solution, including sample data and expected output.

Uploaded by

shaurya95076
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Final DBMS File.word-1

The document outlines the vision and mission of the School of Computer Science and Applications, aiming to provide high-quality education and ethical empowerment through innovative technology. It includes a detailed index of practical SQL queries related to employee and customer data management, showcasing various database operations. Each query is accompanied by a solution, including sample data and expected output.

Uploaded by

shaurya95076
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

School of computer

science and application

DataBase Management System

(DBMS) LAB
roll No : 2466003027
Semester: 2nd Code :- MCA-127P
Submitted by:
Submitted To:

prakhar Seth Mr. Atul Kumar


Vision

To be a world - class university imparting knowledge and

values and providing students, an excellent learning

experience through research & innovation in the field of

Science, Technology, Management and other areas that will

meet the aspirations of world community.

Mission

University stands for academic, professional and ethical

empowerment of the youths by using the state-of-the-art

technology, time-tested and innovative concepts, excellent

infrastructure and internationally acclaimed facilitators.


School of Computer Science & Applications
(SoCSA)

VISION

To achieve heights in computer education domain by creating appropriate


environment for students, faculties and staff with availability of latest
technological infrastructure.

MISSION

1. To dissipate appropriate all types of practical and theoretical computer


science knowledge to our young students.
2. Inculcate professional efficiency in the students for brighter career
opportunity as per industry latest requirement.
3. To provide learning environment for students with our reputed academics
partner in the field of computer science.
4. To prepare our student as an IT professional with full of ethics and human
values.
INDEX
Sr. No. Name of Practical Date Sign.
1. Create a query to display the name and salary of employees 21-02-25
earning more than Rs. 12,000. [EMPLOYEE (Emp_id,
name, salary, Address, Dep_no, Dep_name)].
2. Create a query to display the employee name and 27-02-25
department number for employee_id 176. [EMPLOYEE
(Emp_id, name, salary, Address, Dep_no, Dep_name)].
3. Display the name and salary for all employees whose 03-03-25
salary is not in the range of 5,000 and 12,000.
[EMPLOYEE (Emp_id, name, salary, Address, Dep_no,
Dep_name)].
4. List the name and salary of employees who earn between 07-03-25
5,000 and 12,000, and are in department 20. [EMPLOYEE
(Emp_id, name, salary, Address, Dep_no, Dep_name)].
5. Display the names of all employees where the second 17-03-25
letter of the name is an “a”. [EMPLOYEE (Emp_id, name,
salary, Address, Dep_no, Dep_name)].
6. Display the names of all employees whose name starts 21-03-25
with “a”. [EMPLOYEE (Emp_id, name, salary, Address,
Dep_no, Dep_name)].
7. Select ID, Name and Salary fields from the CUSTOMERS 27-03-25
table where salary is greater than 2000. [ Customer (ID,
name, Salary)].
8. Select ID, Name and Salary fields from the CUSTOMERS 01-04-25
table for a customer with name Hardik. [ Customer (ID,
name, Salary)].
9. Select Name and Salary fields of the customers available 04-04-25
in CUSTOMERS table: . [ Customer (ID, name, Salary)].
10. Select Name and Salary fields of the customers available 09-04-25
in CUSTOMERS table where salary contains null value. [
Customer (ID, name, Salary)].
11. Select ID, Name and Salary fields from the CUSTOMERS 16-04-25
table where salary is greater than 2000 OR age is less than
25 years: .[ Customer (ID, name, Salary, age)].
12. Find all records from Employee table whose employee 21-04-25
name starts with A and ends with T. [EMPLOYEE
(Emp_id, Name, salary, Address, Dep_no, Dep_name)].
13. Find number of employees from Employee table. 24-04-25
[EMPLOYEE (Emp_id, Name, salary, Address, Dep_no,
Dep_name)].
14. Select the name from Employee table and show them in 28-04-25
Ascending order. [EMPLOYEE (Emp_id, name, salary,
Address, Dep_no, Dep_name)].
15. Find Average salary of Employees. [EMPLOYEE 02-05-25
(Emp_id, name, salary, Address, Dep_no, Dep_name)].
16. Find maximum salary from Employee table.[EMPLOYEE 06-05-25
(Emp_id, name, salary, Address, Dep_no, Dep_name)].
17. Find Maximum and minimum salary from Employee 08-05-25
table. [EMPLOYEE (Emp_id, name, salary,
Address, Dep_no, Dep_name)].
18. Find the number of employees in each department (use 13-05-25
Group by Function). [EMPLOYEE (Emp_id, name, salary,
Dep_name)].
19. Display employee name, id, Dep name and salary of all 16-05-25
employees whose name begin with ‘T’ and salary greater
than 10000. [EMPLOYEE (Emp_id, name, salary,
Dep_name)].
20. Find name and salary from employee table show the 19-05-25
Employees salary in Descending Order [EMPLOYEE
(Emp_id, name, salary, Dep_name)].
Ques l. Create a query to display the name and salary of employees
earning more than Rs. 12,000. [EMPLOYEE (Emp_id, name,

salary, Address, Dep_no, Dep_name)].

Sol :-
Employee_Table :

Emp_id name salary Address Dep_no Dep_name


1 Manoj Rana 15000 Chajjarpur D1 Sales
2 Khushi 12500 Meerut D2 Accountant
3 Tarushi Garg 10000 Parikshit Garh D3 purchase
4 Priyanshu Tyagi 11000 Parikshit Garh D2 Sales
5 Gaurav Ghansela 13000 Uttra Khand D1 Accountant

SQL Query :

Select name, salary

From Employee

Where salary>12000;

Output :

name salary
Manoj Rana 15000
Khushi 12500
Gaurav Ghansela 13000

1
Ques 2. Create a query to display the employee name and department
number for employee_id 176. [Employee (Emp_id, name, salary,

Address, Dep_no, Dep_name)].


Sol :-
Employee_Table :

Emp_id name salary Address Dep_no Dep_name


175 Manoj Rana 15000 Chajjarpur D1 Sales
176 Khushi 12500 Meerut D2 Accountant
177 Tarushi Garg 10000 Parikshit Garh D3 purchase
178 Priyanshu Tyagi 11000 Parikshit Garh D2 Sales
179 Gaurav Ghansela 13000 Uttra Khand D1 Accountant

SQL Query :

SELECT name, Dep_no

FROM EMPLOYEE

WHERE Emp_id = 176;

Output :

name Dep_no
Khushi D2

2
Ques 3. Display the name and salary for all employees whose salary
is not in the range of 5,000 and 12,000. [Employee (Emp_id, name,
salary, Address, Dep_no, Dep_name)].

Sol :-
Employee_Table :

Emp_id name Salary Address Dep_no Dep_name


1 Manoj Rana 15000 Chajjarpur D1 Sales
2 Khushi 12500 Meerut D2 Accountant
3 Tarushi Garg 10000 Parikshit Garh D3 purchase
4 Priyanshu Tyagi 4000 Parikshit Garh D2 Sales
5 Gaurav Ghansela 11000 Uttra Khand D1 Accountant

SQL Query :

SELECT name, salary

FROM EMPLOYEE

WHERE salary NOT BETWEEN 5000 AND 12000;

Output :

name salary
Manoj Rana 15000
Khushi 12500
Priyanshu Tyagi 4000

3
Ques 4. List the name and salary of employees who earn between
5,000 and 12,000, and are in department20. [(EMPLOYEE
(Emp_id, name, salary, Address, Dep_no, Dep_name)].
Sol :-
Employee_Table :

Emp_id name salary Address Dep_no Dep_name


1 Manoj Rana 15000 Chajjarpur 10 Sales
2 Khushi 12500 Meerut 20 Accountant
3 Tarushi Garg 10000 Parikshit Garh 20 purchase
4 Priyanshu Tyagi 4000 Parikshit Garh 30 Sales
5 Gaurav Ghansela 11000 Uttra Khand 20 Accountant

SQL Query :

SELECT name, salary

FROM EMPLOYEE

WHERE salary BETWEEN 5000 AND 12000

AND Dep_no = 20;

Output :

name salary
Tarushi Garg 10000
Gaurav Ghansela 11000

4
Ques 5. Display the names of all employees where the second letter of
the name is an "a". [EMPLOYEE (Emp_id, name, salary,
Address, Dep_no, Dep_name)].

Sol :-
Employee_Table :

Emp_id name salary Address Dep_no Dep_name


1 Manoj Rana 15000 Chajjarpur 10 Sales
2 Khushi 12500 Meerut 20 Accountant
3 Tarushi Garg 10000 Parikshit Garh 20 purchase
4 Priyanshu Tyagi 4000 Parikshit Garh 30 Sales
5 Gaurav Ghansela 11000 Uttra Khand 20 Accountant

SQL Query :
SELECT name

FROM EMPLOYEE

WHERE name LIKE '_a%';

Output :

name
Manoj Rana
Tarushi Garg
Gaurav Ghansela

5
Ques 6. Display the names of all employees whose name starts with “a”.
[EMPLOYEE (Emp_id, name, salary, Address, Dep_no, Dep_name)].
Sol :-
Employee_Table :

Emp_id name salary Address Dep_no Dep_name


1 Manoj Rana 15000 Chajjarpur 10 Sales
2 Khushi 12500 Meerut 20 Accountant
3 Tarushi Garg 10000 Parikshit Garh 20 purchase
4 aditi Garg 4000 Parikshit Garh 30 Sales
5 Gaurav Ghansela 11000 Uttra Khand 20 Accountant

SQL Query :

SELECT name

FROM EMPLOYEE

WHERE name LIKE 'a%';

Output :

name
aditi Garg

6
Ques 7. Select ID, Name and Salary fields from the CUSTOMERS table
where salary is greater than 2000. [Customer (ID, name, Salary)].
Sol :-
Customer_Table :

ID name Salary age


1 Manoj Rana 3200 22
2 Khushi 1800 24
3 Tarushi Garg 2000 21
4 Priyanshu Tyagi 2200 23
5 Gaurav Ghansela 2500 22

SQL Query :

Select ID, name, Salary

FROM customer

WHERE salary >2000;

Output :

ID name Salary
1 Manoj Rana 3200
4 Priyanshu Tyagi 2200
5 Gaurav Ghansela 2500

7
Ques 8. Select ID, Name and Salary fields from the CUSTOMERS table for
a customer with name Hardik. [Customer (ID, name, Salary)].
Sol :-
Customer_Table :

ID Name Salary age


1 Hardik 3200 22
2 Khushi 1800 24
3 Tarushi Garg 2000 21
4 Priyanshu Tyagi 2200 23
5 Gaurav Ghansela 2500 22

SQL Query :

SELECT ID, name, Salary

FROM CUSTOMER

WHERE name = 'Hardik';

Output :

ID name Salary
1 Hardik 3200

8
Ques 9. Select Name and Salary fields of the customers available in CUSTOMERS
table. [Customer (ID, name, Salary)].
Sol :-
Customer_Table :

ID name Salary age


1 Manoj Rana 3200 22
2 Khushi 1800 24
3 Tarushi Garg 2000 21
4 Priyanshu Tyagi 2200 23
5 Gaurav Ghansela 2500 22

SQL Query :

SELECT name, salary

FROM Customers;

Output :

name salary
Manoj Rana 3200
Khushi 1800
Tarushi Garg 2000
Priyanshu Tyagi 2200
Gaurav Ghansela 2500

9
Ques 10. Select Name and Salary fields of the customers available in CUSTOMERS
table where salary contains null value. [Customer (ID, name, Salary)].

Sol :-
Customer_Table :

ID name Salary age


1 Manoj Rana NULL 22
2 Khushi 1800 24
3 Tarushi Garg NULL 21
4 Priyanshu Tyagi 2200 23
5 Gaurav Ghansela 2500 22

SQL Query :

SELECT name, Salary

FROM CUSTOMER

WHERE Salary IS NULL;

Output :

name salary
Manoj Rana NULL
Tarushi Garg NULL

10
Ques 11. Select ID, Name and Salary fields from the CUSTOMERS table
where salary is greater than 2000 OR age is less than 25 years.

[Customer (ID, name, Salary, age)].

Sol :-
Customer_Table :

ID name Salary age


1 Manoj Rana 3200 22
2 Khushi 1800 24
3 Tarushi Garg 2000 26
4 Priyanshu Tyagi 2200 25
5 Gaurav Ghansela 2500 27

SQL Query :

SELECT ID, name, Salary

FROM CUSTOMER

WHERE Salary > 2000 OR age < 25;

Output :

ID name Salary
1 Manoj Rana 3200
2 Khushi 1800

11
Ques 12. Find all records from Employee table whose employee name starts with
A and ends with T. [EMPLOYEE (Emp_id, Name, salary, Address, Dep_no,
Dep_name)].
Sol :-
Employee_Table :

ID name Salary age


1 Amit 3200 22
2 Khushi 1800 24
3 Tarushi Garg 2000 26
4 Ankit 2200 25
5 Gaurav Ghansela 2500 27

SQL Query :

SELECT * FROM EMPLOYEE


WHERE name LIKE 'A%T';

Output :

ID name salary age


1 Amit 3200 22
4 Ankit 2200 25

12
Ques 13. Find number of employees from Employee table. [EMPLOYEE (Emp_id,

name, salary, Address, Dep_no, Dep_name)].


Sol :-
Employee_Table :

Emp_id name salary Address Dep_no Dep_name


1 Manoj Rana 15000 Chajjarpur 10 Sales
2 Khushi 12500 Meerut 20 Accountant
3 Tarushi Garg 10000 Parikshit Garh 20 purchase
4 Priyanshu Tyagi 4000 Parikshit Garh 30 Sales
5 Gaurav Ghansela 11000 Uttra Khand 20 Accountant

SQL Query :

SELECT COUNT (*) AS total_employees

FROM EMPLOYEE;

Output :

Total_Employees
5

13
Ques 14. Select the name from Employee table and show them in ascending
order. (EMPLOYEE (Emp_id, name, salary, Address, Dep_no,
Dep_name)].
Sol :-
Employee_Table :

Emp_id name salary Address Dep_no Dep_name


1 Manoj Rana 15000 Chajjarpur 10 Sales
2 Khushi 12500 Meerut 20 Accountant
3 Tarushi Garg 10000 Parikshit Garh 20 purchase
4 Priyanshu Tyagi 4000 Parikshit Garh 30 Sales
5 Gaurav Ghansela 11000 Uttra Khand 20 Accountant

SQL Query :

SELECT name

FROM EMPLOYEE

ORDER BY name ASC;

Output :

name
Gaurav Ghansela
Khushi
Manoj Rana
Priyanshu Tyagi
Tarushi Garg

14
Ques 15. Find Average salary of Employees. [EMPLOYEE (Emp_id, name, salary,

Address, Dep_no, Dep_name)].


Sol :-
Employee_Table:

Emp_id name salary Address Dep_no Dep_name


1 Manoj Rana 15000 Chajjarpur 10 Sales
2 Khushi 12500 Meerut 20 Accountant
3 Tarushi Garg 10000 Parikshit Garh 20 purchase
4 Priyanshu Tyagi 4000 Parikshit Garh 30 Sales
5 Gaurav Ghansela 11000 Uttra Khand 20 Accountant

SQL Query :
SELECT AVG(salary) AS average_salary

FROM EMPLOYEE;

Output :

Average_salary

10500

15
Ques 16. Find maximum salary from Employee table. [EMPLOYEE (Emp_id,

name, salary, Address, Dep_no, Dep_name)].


Sol :-
Employee_Table :

Emp_id name salary Address Dep_no Dep_name


1 Manoj Rana 15000 Chajjarpur 10 Sales
2 Khushi 12500 Meerut 20 Accountant
3 Tarushi Garg 10000 Parikshit Garh 20 purchase
4 Priyanshu Tyagi 4000 Parikshit Garh 30 Sales
5 Gaurav Ghansela 11000 Uttra Khand 20 Accountant

SQL Query :

Select max(salary) As maximum_salary

FROM Employee;

Output :

Maximum_salary
15000

16
Ques 17. Find Maximum and minimum salary from Employee table.

[EMPLOYEE (Emp_id, name, salary, Address, Dep_no, Dep_name)].


Sol :-
Employee_Table :

Emp_id name salary Address Dep_no Dep_name


1 Manoj Rana 15000 Chajjarpur 10 Sales
2 Khushi 12500 Meerut 20 Accountant
3 Tarushi Garg 10000 Parikshit Garh 20 purchase
4 Priyanshu Tyagi 4000 Parikshit Garh 30 Sales
5 Gaurav Ghansela 11000 Uttra Khand 20 Accountant

SQL Query :

SELECT MAX(salary) AS maximum_salary, MIN(salary) AS minimum_salary


FROM EMPLOYEE;

Output :

Maximum_salary Minimum_salary
15000 4000

17
Ques 18. Find the number of employees in each department (use Groupby
Function). [EMPLOYEE (Emp_id, name, salary, Dep_name)].
Sol :-
Employee_Table :

Emp_id name salary Address Dep_no Dep_name


1 Manoj Rana 15000 Chajjarpur 10 Sales
2 Khushi 12500 Meerut 20 Accountant
3 Tarushi Garg 10000 Parikshit Garh 20 purchase
4 Priyanshu Tyagi 4000 Parikshit Garh 30 Sales
5 Gaurav Ghansela 11000 Uttra Khand 20 Accountant

SQL Query :

SELECT Dep_name, COUNT(*) AS total_employees

FROM EMPLOYEE

GROUP BY Dep_name;

Output :

Dep_name Total_employee

Sales 2

Accountant 2

purchase 1

18
Ques 19. Display employee name, id, Dep_name and salary of all
employees whose name begin with 'T' and salary greater than

10000. [EMPLOYEE (Emp_id, name, salary, Dep_name)].


Sol :-
Employee_Table :

Emp_id name salary Dep_name


1 Tanu 11000 Sales
2 Tom 12500 Accountant
3 Manoj Rana 8000 Purchase
4 Khushi 15000 Sales
5 Tarun 13000 Purchase

SQL Query :

SELECT Emp_id, name, Dep_name, salary

FROM EMPLOYEE

WHERE name LIKE 'T%' AND salary > 10000;

Output :

Emp_id name salary Dep_name


1 Tanu 11000 Sales
2 Tom 12500 Accountant
5 Tarun 13000 Purchase

19
Ques 20. Find name and salary from employee table show the Employees

salary in Descending Order. [EMPLOYEE (Emp_id, name, salary,

Dep_name)].

Sol :-
Employee_Table :

Emp_id name salary Dep_name


1 Tanu 11000 Sales
2 Tom 12500 Accountant

3 Manoj Rana 8000 Purchase


4 Khushi 15000 Sales
5 Tarun 13000 Purchase

SQL Query :
SELECT name, salary

FROM EMPLOYEE

ORDER BY salary DESC;

Output-

name salary
Khushi 15000
Tarun 13000
Tom 12500
Tanu 11000
Manoj Rana 8000

20

You might also like