Professional Documents
Culture Documents
Ankit Vashisth Ji
Ankit Vashisth Ji
WORKSHEET 2.1
1. Aim: (i) Create a relation employee with following attributes emp_no NOT
NULL INT, emp_name VARCHAR(10), job VARCHAR(9), hier_date INT,
dept_number INT, age INT, e_salary INT
a) List minimum , maximum and average salary of employee.
b) What is difference between maximum and minimum salary of employee
in the organisation.
c) Display all emp_name and salary whose salary is greater than
minimum salary of the company and job tittle starts with "M". d)
Display lowest paid employee details under each manager.
(ii) Write a PL/SQL code to print table of a number.
2. Source Code:
(i)
CREATE TABLE employee (
emp_no INT NOT NULL,
emp_name VARCHAR(30),
job VARCHAR(20),
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
hier_date INT,
dept_number INT, age INT,
e_salary INT, manager_id
INT, PRIMARY KEY
(emp_no)
);
INSERT INTO employee VALUES
(1, 'Gaurav', 'Manager', 2022, 101, 35, 60000, NULL),
(2, 'Tushar', 'Manager', 2021, 102, 32, 58000, NULL),
(3, 'Deep', 'Developer', 2018, 101, 28, 50000, 1),
(4, 'Shorey', 'Marketer', 2010, 102, 30, 52000, 2),
(5, 'Mohan', 'Manager', 2022, 103, 40, 62000, NULL),
(6, 'Somya', 'Developer', 2022, 103, 27, 48000, 5),
(7, 'Mahi', 'Marketer',2022, 101, 29, 51000, 1);
3. Screenshot of Outputs:
(d)Fourth output:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
(ii) PL/SQL code to print table of a number:
declare
num int := 5;
Begin
For i in 1 .. 10 loop
dbms_output.put_line(num*i);
end loop;
end;
(ii) Output :