You are on page 1of 8

Experiment 2.

Student Name: Vishal Singh UID: 21BCA1253


Branch: BCA (UIC) Section/Group:- 3(A)
Semester: 2nd Date of Performance: 26 Oct. 22
Subject Name: DMBS Subject Code: 21CAP-215_ON21BCA-3

1. Aim/Overview of the practical:


 Create table naming employee_details having following columns:
 E_id : primary key
 E_name
 E_dept : not null (can be finance, marketing, accounts, admin, developer)
 E_location : not null (can be Delhi, Mumbai, Pune, Hyderabad)
 E_doj
 Insert any 10 queries as per the requirement of the table.
 Display only those details of employees having location = “Delhi”.
 Display only those employee details whose department is “accounts”.
 Implement group by clause on the department and generate the number of same department
occurrences.

 Arrange the employee details as per the ascending order of E_name.


 Display the distinct values as per the E_dept.
 Display those employees information whose date of joining is before 2019.
2. Task to be done:
a) Write the syntax for each command.
use my_database;
create table employees_detail (
    E_id int (10) primary key,
    E_name varchar(30),
    E_dept varchar(30),
    E_location varchar(30) not null,
    E_doj date
);
insert into employees_detail value(101, 'Vishal', 'programmer', 'Delhi', '2022-01-01');
insert into employees_detail value(102, 'Mohit', 'account', 'Mumbai', '2018-11-11');
insert into employees_detail value(103, 'Priyanshi', 'finance', 'Delhi', '2016-12-11');
insert into employees_detail value(104, 'Zengy', 'programmer', 'Hadrabad', '2017-09-08');
insert into employees_detail value(105, 'Harsh', 'account', 'Puna', '2022-04-05');
insert into employees_detail value(106, 'Kundan', 'Marketing', 'Mumbai', '2022-06-07');
insert into employees_detail value(107, 'Utsav', 'programmer', 'Delhi', '2022-08-09');
insert into employees_detail value(108, 'Ritesh', 'programmer', 'Hadrabad', '2022-10-11');
insert into employees_detail value(109, 'Rahul', 'finance', 'Puna', '2022-07-07');
insert into employees_detail value(110, 'Sandhya', 'account', 'Delhi', '2019-02-03');
select *
from employees_detail;
select *
from employees_detail
where E_location = 'delhi';
select *
from employees_detail
where E_dept = 'account';
select *
from employees_detail
order by E_name;
select distinct E_dept
from employees_detail;
SELECT *
FROM employees_Detail
WHERE E_doj <('2019-01-01');

b) Give appropriate example after creating a table and insertion in that table.

  E_id E_name E_dept E_location E_doj


  101 Vishal programmer Delhi 2022-01-01
  102 Mohit account Mumbai 2018-11-11
  103 Priyanshi finance Delhi 2016-12-11
  104 Zengy programmer Hadrabad 2017-09-08
  E_id E_name E_dept E_location E_doj
  105 Harsh account Puna 2022-04-05
  106 Kundan Marketing Mumbai 2022-06-07
  107 Utsav programmer Delhi 2022-08-09
  108 Ritesh programmer Hadrabad 2022-10-11
  109 Rahul finance Puna 2022-07-07
  110 Sandhya account Delhi 2019-02-03
 

c) Write the output.

Display only those details of employees having location = “Delhi”.

select * from employees_detail where E_location = 'delhi';


101 Vishal programmer Delhi 2022-01-01
103 Priyanshi finance Delhi 2016-12-11
107 Utsav programmer Delhi 2022-08-09
110 Sandhya account Delhi 2019-02-03

Display only those employee details whose department is “accounts”.

select *
from employees_detail
where E_dept = 'account';
102 Mohit account Mumbai 2018-11-11
105 Harsh account Puna 2022-04-05
110 Sandhya account Delhi 2019-02-03

Arrange the employee details as per the ascending order of E_name.

select *
from employees_detail
order by E_name;
105 Harsh account Puna 2022-04-05
106 Kundan Marketing Mumbai 2022-06-07
102 Mohit account Mumbai 2018-11-11
103 Priyanshi finance Delhi 2016-12-11
109 Rahul finance Puna 2022-07-07
108 Ritesh programmer Hadrabad 2022-10-11
110 Sandhya account Delhi 2019-02-03
107 Utsav programmer Delhi 2022-08-09
101 Vishal programmer Delhi 2022-01-01
104 Zengy programmer Hadrabad 2017-09-08

Display the distinct values as per the E_dept.

select distinct E_dept from employees_detail;


programmer
account
finance
Marketing
Display those employees information whose date of joining is before 2019.

SELECT *
FROM employees_Detail
WHERE E_doj <('2019-01-01');
102 Mohit account Mumbai 2018-11-11
103 Priyanshi finance Delhi 2016-12-11
104 Zengy programmer Hadrabad 2017-09-08

3. . Steps for experiment/practical:


 Firstly we need to open SQL IDEs.
 Then create a database.
 After that we need to create a Project table.
 Then we create 5 columns with its data type and size.
 After that we Insert the Values of 10 record and implement it.
 And after that we do the task which is given in the question.

4. Result/Output/Writing Summary:
1. Learning outcomes (What I have learnt):

1. Learned to arranging into ascending order.

2. Printing the table.

3. Learned how to use tools.

Evaluation Grid:
Sr. No. Parameters Marks Obtained Maximum Marks
1. Demonstration and 5
Performance (Pre Lab Quiz)
2. Worksheet 10
3. Post Lab Quiz 5

You might also like