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

Dbms Lab: IIIT Agartala

The document describes an experiment on studying NULL operators and performing calculations in runtime queries in a database called EMPLOYEE_19UICS008 created using XAMPP software. It involves creating an Emp table with multiple columns, inserting sample data, and running various queries to retrieve, modify and delete data based on conditions. The key goals are to understand how to use NULL operators in queries and perform calculations within queries.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Dbms Lab: IIIT Agartala

The document describes an experiment on studying NULL operators and performing calculations in runtime queries in a database called EMPLOYEE_19UICS008 created using XAMPP software. It involves creating an Emp table with multiple columns, inserting sample data, and running various queries to retrieve, modify and delete data based on conditions. The key goals are to understand how to use NULL operators in queries and perform calculations within queries.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

DBMS LAB

Submission by:-
Anand Kumar
(19UICS008/1911291)

IIIT Agartala
Experiment NO.3
Date :- 14/09/2021
Objective:- To study about NULL operator and performing
calculation on runtime query.
Equipment:- XAMPP Software.
 Create a Database called EMPLOYEE_Your Roll Number.
 Create a Table called emp with following columns.
EMPNO INT
ENAME VARCHAR (10)
JOB VARCHAR (9)
MGR INT
HIREDATE VARCHAR(9)
SAL INT
COMM INT
DEPTNO INT
AGE INT
ESAL INT

Query :-
CREATE TABLE Emp( EMPNO INT, ENAME VARCHAR(10), JOB
VARCHAR(9), MGR INT, HIREDATE VARCHAR(9), SAL INT, COMM INT,
DEPTNO INT, AGE INT, ESAL INT );

Result :
 Insert the following data into the emp table.

Query :-
INSERT INTO emp VALUES
(7369,'SMITH','CLERK',7902,'17-DEC-80',800,0,20,25,0),
(7499,'ALLEN','SALESMAN',7698,'20-FEB-81',1600,300,30,25,0),
(7521,'WARD','SALESMAN',7698,'22-FEB-81',1250,500,30,25,0),
(7566,'JONES','MANAGER',7839,'02-APR-81',2975,500,20,25,0),
(7698,'KE','MANAGER',7839,'01-MAY-81',2850,1400,30,25,0);

Result :
Q. No.1 :- List all employee names and their salaries, whose salary lies between
1500/- and 3500/- both inclusive.
Query :- SELECT ENAME, SAL FROM emp WHERE SAL BETWEEN 1500 AND 3500;
Result:-

Q.No.2 :- List all employee names and their and their manager whose manager is
7902 or 7566 or 7789.
Query :-
SELECT ENAME, MGR FROM emp WHERE (MGR = 7902) OR(MGR = 7566) OR(MGR = 7789);

Result:-
Q.No.3 :- List all employees, which starts with either J or T.

Query :- SELECT * FROM emp WHERE ENAME LIKE 'J%' OR ENAME LIKE 'T%';
Result:-

Q.No.4 :- List all employee names and jobs, whose job title includes M or P.
Query :- SELECT ENAME, JOB FROM emp WHERE JOB LIKE '%M%' OR JOB LIKE '%P%';

Result:-
Q.No.5 :- List all jobs available in employee table.

Query :- SELECT DISTINCT JOB FROM emp;

Result:-

Q.No.6 :-List all employees who belongs to the department 10 or 20.

Query :- SELECT * FROM emp WHERE DEPTNO IN(10, 20);


Result:-
Q.No.7:-List all employee names, salary and 15% rise in salary.

Query :- SELECT ENAME, SAL, 1.15 * SAL AS 'RAISE' FROM emp;

Result:-

Q.No.8:-List minimum, maximum, average salaries of employee.

Query :- SELECT MIN(SAL) AS 'MIN', MAX(SAL) AS 'MAX', AVG(SAL) AS 'AVG' FROM emp;

Result:-
Q.No.9:-Find how many job titles are available in employee table.

Query :- SELECT COUNT(DISTINCT JOB) FROM emp;

Result:-

Q.No.10:-Find how much amount the company is spending towards salaries.

Query :- SELECT SUM(SAL) FROM emp;


Result:-
Q.No.11:-Display name of the dept. with dept no 20.

Query :-
SELECT ENAME FROM emp WHERE DEPTNO = 20;SELECT ENAME FROM emp WHERE DEPTNO = 20;

Result:-

Q.No.12:-List ENAME whose commission is NULL.

Query :- SELECT ENAME FROM emp WHERE COMM = NULL;


Result:-
Q.No.13:-Find no.of dept in employee table.

Query :- SELECT COUNT(DISTINCT DEPTNO) FROM emp;

Result:-

Q.No.14:-List ENAME whose manager is not NULL.

Query :- SELECT ENAME FROM emp WHERE MGR = NULL;


Result:-
Q.No.15:-Change the AGE to 30 whose JOB is MANAGER.

Query :- UPDATE emp SET AGE = 30 WHERE JOB = 'manager';


Result:-

Q.No.16:-Modify ESAL to 20000/- whose MGR is 7698.

Query :- UPDATE emp SET ESAL = 20000 WHERE MGR = 7698;


Result:-
Q.No.17:-Delete the record whose HIREDATE is 01-MAY-81.

Query :- DELETE FROM emp WHERE HIREDATE ='01-MAY-81';


Result:-

Conclusion :-
In above experiment we learnt about NULL operator
and learnt how we can perform the calculation on runtime
query.

You might also like