0% found this document useful (0 votes)
17 views10 pages

DBMS File

The document outlines practical work for a BCA course, focusing on database management using SQL. It includes tasks such as creating tables, inserting records, and executing various SQL queries to manipulate and retrieve employee and salesman data. Each task is numbered and detailed with corresponding SQL statements for implementation.
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)
17 views10 pages

DBMS File

The document outlines practical work for a BCA course, focusing on database management using SQL. It includes tasks such as creating tables, inserting records, and executing various SQL queries to manipulate and retrieve employee and salesman data. Each task is numbered and detailed with corresponding SQL statements for implementation.
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/ 10

School of IT

Ins tute of Management Studies – Noida

BCA (2023-24)
Computer Laboratory and Prac cal Work
DBMS BCA- 505

Submi ed To: - Submi ed By: -


Ms. Dhwani Garg
Assistant Professor – SOIT
INDEX
S.NO TITLE PAGE SIGN
NO
1 Create table for Employee (E-id, E-name, salary, dept) and E-id as 1
primary key
2 Insert at least 5 records. 1
3 Display all records. 1
4 Display E_name and salary of all employees 2
5 Display employee in alphabe cal order. 2
6 List the employee whose employee number is 100. 2
7 List the Employee whose salary is between 20 000 to 40000 3

8 List all employees who belongs to 'HR' or 'MKT' or ' Prod' 3


department.
9 List the Employees whose name starts with' A' 3
10 List all employees whose name second character is 'a' 3
11 List the Employees whose name starts with P, B, R characters. 4
12 Calculate the total salary. 4
13 Calculate the average salary of employees. 4
14 Find out the minimum salary of employees. 4
15 Find out the maximum salary of employee. 4
16 To count the total number of employees who belongs to marke ng 5
dept.
17 Create Salesman Table salesman_id | name | city | commission. 5-6
18 Write a SQL statement to find those salesmen with all informa on 6
who come from the city either Paris or Rome.
19 Write a query to sort out those sales man with all informa on whose 6
ID value is within any of 5007, 5003 and 5005.
20 Write a SQL statement to find those salesmen with all informa on 7
who gets the commission within a range of 0.12 and 0.14.
21 Write a SQL statement to find those salesmen with all other 7
informa on and name started with any le er within 'A' and 'K'.
22 Write a SQL statement to find those salesmen with all other 7
informa on and name started with other than any la er within 'A'
and 'L'
23 Write a SQL statement to find that salesman with all informa on 8
whose name begin with the le er 'P'.
24 Write a SQL statement to find all those sales man with all 8
informa on whose names are ending with the le er ‘n’
25 Select the detail of the employee whose name start with P 8
Q.1 Create table for Employee (E-id, E-name, salary, dept) and E-id as primary key.
CREATE TABLE Employee (
E_id INT PRIMARY KEY,
E_name VARCHAR(255),
Salary NUMERIC(8, 2),
Dept VARCHAR(255) );
Q.2 Insert at least 5 records.
-- Inserting records into the Employee table
INSERT INTO Employee (E_id, E_name, Salary, Dept)
VALUES
(1, 'Aditya', 100000.00, 'HR'),
(2, 'Nimisaa', 90000.00, 'Marketing'),
(3, 'Sahil', 85000.00, 'IT'),
(4, 'Himadri', 50000.00, ‘Sales’),
(5, ‘Jayesh', 80000.00, Accounting);

Q.3 Display all records.

SELECT * FROM Employee;

pg. 1
Q.4 Display E_name and salary of all employees

SELECT E_name, salary


FROM Employee;

Q.5 Display employee in alphabetical order.


SELECT E_name, salary
FROM Employee
ORDER BY E_name ASC;

Q.6 List the employee whose employee number is 100.

SELECT * FROM employees WHERE employee_number = 100;

pg. 2
Q.7 List the Employee whose salary is between 20 000 to 40000.

SELECT * FROM employees WHERE salary BETWEEN 20000 AND 40000;

Q.8 List all employees who belongs to 'HR' or 'MKT' or ' Prod' department.

SELECT * FROM employees WHERE department IN ('HR', 'MKT', 'Prod');

Q.9 List the Employees whose name starts with' A'

SELECT * FROM employees WHERE name LIKE 'A%';

Q.10 List all employees whose name second character is 'a'

SELECT * FROM Employee WHERE E_name LIKE '_a%'

pg. 3
Q.11 List the Employees whose name starts with P, B, R characters.
SELECT * FROM Employee
WHERE E_name LIKE 'P%' OR E_name LIKE 'B%' OR E_name LIKE 'R%';

Q.12 Calculate the total salary.


SELECT SUM(salary) AS total_salary FROM Employee

Q.13 Calculate the average salary of employees.


SELECT AVG(salary) AS average_salary FROM Employee

Q.14 Find out the minimum salary of employees.


SELECT MIN(salary) AS min_salary FROM Employee

Q.15 Find out the maximum salary of employee.

SELECT MAX(salary) AS max_salary FROM Employee

pg. 4
Q.16 To count the total number of employees who belongs to marketing dept.
SELECT * FROM Employee
WHERE Dept = 'Marketing'

Q.17 Create Salesman Table salesman_id | name | city | commission.


5001 | James Hoog | New York | 0.15
5002 | Nail Knite | Paris | 0.13
5005 | Pit Alex | London | 0.11
5006 | Mc Lyon | Paris |0.14
5007 | Paul Adam | Rome | 0.13
5003 | Lauson Hen | San Jose | 0.12
CODE: -
CREATE TABLE Salesman (
salesman_id INT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
city VARCHAR(255) NOT NULL,
commission DECIMAL(5,2) NOT NULL
);
INSERT INTO salesman VALUES (5001, 'James Hoog', 'New York', 0.15);

INSERT INTO salesman VALUES (5002, 'Nail Knite', 'Paris', 0.13);

INSERT INTO salesman VALUES (5005, 'Pit Alex', 'London', 0.11);

INSERT INTO salesman VALUES (5006, 'Mc Lyon', 'Paris', 0.14);

INSERT INTO salesman VALUES (5007, 'Paul Adam', 'Rome', 0.13);

INSERT INTO salesman VALUES (5003, 'Lauson Hen', 'San Jose', 0.12);

pg. 5
Q.18 Write a SQL statement to find those salesmen with all information who come
from the city either Paris or Rome.
SELECT salesman_id, name, city, commission
FROM salesman
WHERE city IN ('Paris', 'Rome')

Q.19 Write a query to sort out those sales man with all information whose ID value is
within any of 5007, 5003 and 5005.

SELECT * FROM salesman


WHERE salesman_id IN (5007, 5003, 5005);

pg. 6
Q.20 Write a SQL statement to find those salesmen with all information who gets the
commission within a range of 0.12 and 0.14.

SELECT * FROM salesman


WHERE commission BETWEEN 0.12 AND 0.14;

Q.21 Write a SQL statement to find those salesmen with all other information and
name started with any letter within 'A' and 'K'.
SELECT *
FROM salesman
WHERE name LIKE '[A-K]%';

Q.22 Write a SQL statement to find those salesmen with all other information and
name started with other than any latter within 'A' and 'L'
SELECT * FROM salesman
WHERE name NOT LIKE '[A-L]%';

pg. 7
Q.23 Write a SQL statement to find that salesman with all information whose name
begin with the letter 'P'.

SELECT * FROM salesman


WHERE name LIKE 'P%';

Q.24 Write a SQL statement to find all those sales man with all information whose names are
ending with the letter 'n

SELECT * FROM salesman


WHERE name LIKE '%n';

Q.25 Select the detail of the employee whose name start with P

SELECT * FROM employees


WHERE name LIKE 'P%';

pg. 8

You might also like