You are on page 1of 7

Q.

1 Give names of employees as “Employee Names”, department names as “Department


Names”, salary as “Employee Salary”, commission as “Commission”, grade of all those
employees as “Employee Grades” whose managers matches with those managers of
employee number 7521 and whose salary is less than the salary of employee having job
PRESIDENT, also place 0 where commission values are NULL.

select ename "Employee Names", dname "Department Names", sal "Employee Salary", nvl(comm,0)
"Commission", grade "Employee Grades"

from emp, dept, salgrade

where emp.deptno=dept.deptno

and sal between losal and hisal

and mgr=(select mgr from emp where empno=7521)

and sal<(select sal from emp where job='PRESIDENT')


Q.2 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.

select ename "Employee Names", job "Employee Job", mgr "Supervised Manager", loc "Department
Location", dept.deptno "Department Number", decode (job,

'CLERK', sal+sal*.20,

'SALESMAN', sal+sal*.30,

'MANAGER', sal+sal*.60,

'ANALYST', sal+sal*.40,

'PRESIDENT', sal+sal*.40) "Incremented Salary"

from emp, dept

where emp.deptno=dept.deptno
3- Display salary in terms of „$‟ where each $ represents Rs.100.

select lpad(sal,(sal/100),'$')

from emp e
4- Using outer join show employee name , department name and department id.

select ename, dname, e.deptno

from emp e

full outer join dept d

on (e.deptno=d.deptno)
5- Show Cartesian product of table employee and department.

select *

from emp, dept

order by empno asc


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

select substr(ename,4,1)

from emp e

where deptno>10
Task 2
Create table t1 and insert these rows in t1.

You might also like