SQL Lab
SQL Lab
SQL Lab
Overview:
Total 100 points.
There will be two tasks in this assignment. In Part A, you will write query on multiple table. In Part B,
you will write a PL/SQL program very similar to the one in SQL Lab 3. What you need to submit are:
1. the SQL command;
2. the results copy and paste from Oracle SQLPlus Worksheet result window.
Prerequisite: To do this assignment, you need to have the tables created and data inserted as in SQL
Lab 2 Assignment 4. If you are not sure whether you have the right tables and data, you can drop all
your tables and then create tables and insert data using the SQL codes in Assignment 4 Solution.
The logical schema is shown below for your reference, its especially helpful when you write multiple
table queries. Note: some of you might have different table name and attribute name.
Employee
FName
Minit
LName
SSN
BDate
Address
Sex
Salary
SuperSSN
DepNo
Department
DName DepNo MgrSSN
MgrSDate
Dept_Locations
DepNo
DLocation
Project
PName
PNumber
PLocation
DepNo
Works_On
ESSN
PNo
Hours
Dependent
ESSN
Dependent_Name
Sex
BDate
Relationship
14. List the name of employees whose supervisor does not have a supervisor.
15. List the name of employees who both lives (address) and works (department location) in Salt Lake
City.
16. List the name of supervisors who starts to supervise a department before Sep 20, 1976.
Part B. PL/SQL Program
20 points. Write a PL/SQL program that is similar to the one in SQL Lab 3 to generate output as shown
below:
The average salary of male employee is $xxxxx.xx
The average salary of female employee is $xxxxx.xx
The average salary of male / female employee is xx% higher than the average salary of female /
male employee