0% found this document useful (0 votes)
40 views6 pages

Experiment: 1.2: Name - Sant Prasad Pathak UID - 20BET1103 Class & Section - 20Bet1-B Subject-Dbms Lab

The document describes an experiment involving creating an EMP table in a database with columns like EMPNO, ENAME, JOB, etc. It then provides SQL queries to: 1) Find the minimum, maximum, and average salaries of employees 2) Calculate the difference between maximum and minimum salaries 3) Display employee names and salaries greater than the minimum salary whose job starts with "M" 4) Display the total salary spent for each job category 5) Display the lowest paid employee details under each manager

Uploaded by

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

Experiment: 1.2: Name - Sant Prasad Pathak UID - 20BET1103 Class & Section - 20Bet1-B Subject-Dbms Lab

The document describes an experiment involving creating an EMP table in a database with columns like EMPNO, ENAME, JOB, etc. It then provides SQL queries to: 1) Find the minimum, maximum, and average salaries of employees 2) Calculate the difference between maximum and minimum salaries 3) Display employee names and salaries greater than the minimum salary whose job starts with "M" 4) Display the total salary spent for each job category 5) Display the lowest paid employee details under each manager

Uploaded by

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

Experiment : 1.

NAME
Name–:SANT
AnmolPRASAD
SUID PATHAK
UID – 20BET1103
: 20BCS2133
CLASS & SECTION – 20BET1-B Branch : BE-CSE
SUBJECT-
Section DBMS
: 8/B LAB Subject : DBMS

Ques : 2

Create table EMP with the following description :

Name Type
EMPNO NOT NULL NUMBER(4) ENAME
VARCHAR2(10)
JOB VARCHAR2(9) MGR
NUMBER(4) HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2) DEPTNO
NUMBER(3) AGE NUMBER(3)
ESAL NUMBER
a) List minimum , maximum , average salaries of employee.

b) What is the difference between maximum and minimum salaries of employees in the organization?

c)  Display all employee names and salary whose salary is greater than minimum salary of the
company and job title starts with ‘M’.
d) Display total salary spent for each job category.

e) Display lowest paid employee details under each manager. 


CODE –
create table EMP(EMPNO NUMBER(4) NOT NULL, ENAME VARCHAR(10),JOB VARCHAR(9), MGR NUMBER(4),
HIREDATE DATE, SAL NUMBER(7,2),COMM NUMBER(7,2), DEPTNO NUMBER(3), AGE NUMBER(3), ESAL NUMBER);

desc EMP;

insert into EMP values(2173, 'ashu', 'developer' , 7902, '14/feb/2018' ,1560.50, 26.87, 20 ,24, 2000 );
insert into EMP values(2221, 'arpit', 'manager' , 7902, '12/oct/2016' ,2290.50, 66.34, 10 ,23, 3000 );
insert into EMP values(2803, 'sameer', 'salesman' , 7578, '16/jan/2015' ,3250, 100, 20 ,24, 3500 );
insert into EMP values(1014, 'ravi', 'designer' , 7566, '25/dec/2017' ,4000, 112.53, 25 ,20, 4000 );
insert into EMP values(1015, 'surbhi', 'analyst' , 7789, '29/aug/2019' ,3500, 76.89, 10 ,20, 3500 );

select * from EMP;

select min(SAL), max(SAL), avg(SAL) from EMP;

SELECT MAX(SAL) - MIN(SAL) DIFFERENCE


FROM EMP;

SELECT ename, sal, job


from emp ;
where sal > (SELECT min(sal) from emp)) //innerQuery
and job like "M%";

ename, sal, comm,


(sal + ((sal*comm) / 100)) as "total_salary"
from emp;

select empno, sal


from emp
where sal in
(select MIN(sal)
from emp
where empno in
(select empno
from emp
where JOB != 'manager'
group by Empno
)
and
JOB != 'manager' and MGR is not null
group by mgr
)
order by sal asc;
SCREENSHOT –

You might also like