Punjab University College of Information Technology (Pucit) : Database Systems Lab 4

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

PUNJAB UNIVERSITY COLLEGE OF

INFORMATION TECHNOLOGY (PUCIT)

Database Systems Lab 4


IT Morning Fall-15 (New Campus)

Date: 29-03-2017

You are given script of relations in database as follows:

EMP(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)


DEPT(DEPTNO, DNAME, LOC)
SALGRADE(GRADE, LOSAL, HISAL)

Instructions:

• Execute queries on your client machines of Oracle 10g.


• Copy query and the resulting table and paste in a MS Word file and rename it as
BITF15M501 and send it to itf15m@gmail.com with subject lab4.
• Sharing is strictly not allowed in lab work. (As of course it will go in your benefit)To seek
any help, consult with TAs……. Lots of Luck! ☺

Objectives:

• Make you familiar with basic commands of Oracle.

1. Give names of employees as “Names” and 20% increased salary as “Incremented Salary” of all
employees in ascending order and round incremented salary to 2 decimal places.

2. Concatenate names of employees and the job.

3. Give names as “Employee Names”, jobs as “Employee Job”, managers as “Employee


Managers” and grade as “Grade” of those employees who have department number in
between 10 and 30 and the only the first letter or name must be Capital.

4. Give names of employees as “Employee Names”, hire date as “Hiring Date”, number as
“Employee Number”, names of departments as “Department Name” of all employees
that has manager not managers 7698 and 67839 show data in ascending order on
employee number basis.
Teaching Assistants: Instructor:
• Sonia Hayat – BSEF14M515
• Abdul Moid – BSEF14A524 Farhan Ahmad Ch.
5. Give names of employees as “Employee Names”, their salary as “Original Salary”, 20%
increased salary as “Incremented Salary” and the amount of increment as “Increment” of
each employee whose manager is not null and show data in ascending order on salary
basis and names should be in small letters.

6. Give names of employees as “Employee Name”, hire date as “Hiring Date”, location as
“Location”, number of characters in location as “Length of Characters in Location” and
the 4th letter of name of employee as “Employee

7. 4th Letter” of all employees who have department number greater than 10.

8. Give locations of ‘L’ in names of employees.

9. Give location of employees as “Location”, high salary of grade as “High Salary”, low
salary of grade as “Low Salary” of all employees but both salaries should be in 8 digits
long, apply left padding with ‘*’ to complete 8 digits.

10. Give jobs as “Jobs”, names as “Employee Names”, location as “Department Location”
and grade as “Salary Grade” of all employees who have department number multiple of
10.

11. Give current date as “Today Date”, hire date as “Hiring Date”, the total number of weeks
from hire date as “Total Weeks” the total number of months from hire date as “Total
Months” of all employees.

12. Give names as “Employee Names”, hire date as “Hiring Date”, add 8 months in every
hire date of employee as “8 Months Added” and the date of the first Monday after hiring
date as “First Working Week” of all employees.

13. Give hire date as “Original Hire Date”, hire date in format ‘22 November 2014’ as “Date
Format.1” and also in format ‘Twenty Second of November 2014, 12:00 PM’ as
“Format.2” of all employees whose commission is not null.

14. Run the following commands and understand their working. Ask us in case of help.

ROUND (SYSDATE, ‘MONTH)


ROUND (SYSDATE, ‘YEAR’)
TRUNC (SYSDATE, ‘MONTH’)
TRUNC (SYSDATE, ‘YEAR’)
ROUND (194.382 , 2)
ROUND (194.382 , -2)
TRUNC (194.382 , 2)
TRUNC (194.382 , -2)

15. Use case expression


Give employee number as “Employee Names”, job as “Employee Job”, manager as “Supervised
Manager”, location as “Department Location”, department number as “Department Number” and
incremented salary as “Incremented Salary” with these conditions:
Teaching Assistants: Instructor:
• Sonia Hayat – BSEF14M515
• Abdul Moid – BSEF14A524 Farhan Ahmad Ch.
If the employee is working as ‘CLERK’, add 20% to salary.
If the employee is working as ‘SALESMAN’, add 30% to salary.
If the employee is working as ‘MANAGER’, add 60% to salary.
If the employee is working as ‘ANALYST’, add 40% to salary.
If the employee is working as ‘PRESIDENT’, add 90% to salary.

16. Use decode expression


Give employee number as “Employee Names”, job as “Employee Job”, manager as “Supervised
Manager”, location as “Department Location”, department number as “Department Number” and
incremented salary as “Incremented Salary” with these conditions:
If the employee is working as ‘CLERK’, add 20% to salary.
If the employee is working as ‘SALESMAN’, add 30% to salary.
If the employee is working as ‘MANAGER’, add 60% to salary.
If the employee is working as ‘ANALYST’, add 40% to salary.
If the employee is working as ‘PRESIDENT’, add 90% to salary.

Best of Luck

Teaching Assistants: Instructor:


• Sonia Hayat – BSEF14M515
• Abdul Moid – BSEF14A524 Farhan Ahmad Ch.

You might also like