Вы находитесь на странице: 1из 13

QUERIES

1- Show Annual Income of Manager having department number 10, 20 and 30 or show those
supervisor whose salary is between 1000 and 5000.

select ename,job, sal*12 as "Annual Salary", deptno


from emp
where lower(job)='manager'
and deptno in(10,20,30)
or job = 'supervisor' and sal between 1000 and 5000

2- 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 of name must be Capital.

select initcap(ename) as "Employee Names", job as "Employee Job", mgr as "Employee Managers",
grade as "Grade"
from emp, dept, salgrade
where dept.deptno>10 and dept.deptno < 30
and emp.deptno = dept.deptno
and (emp.sal>losal and emp.sal<hisal)

3- Show employee names and their jobs as “KING IS A CLERK”.

select '"' || ename || ' IS A ' || job || '"'


from emp
4- 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. \

select ename as Names, sal+round(sal*0.20,2) as "Incremented Salary"


from emp
order by sal asc
5- 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 managers 7698,
67839 and not managers. show data in ascending order on employee number basis.

select ename as "Employee Names", hiredate as "Hiring Date", empno as "Employee Number", dname
as "Department Name", job,mgr

from emp, dept

where lower(job) <> 'manager'

and mgr in(7698,7839)


order by empno asc

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.

select ename as "Employee Name", hiredate as "Hiring Date", loc as "Location", length(loc) as
"Length of Location", substr(ename,4,1) as "Employee"
from emp, dept
where emp.deptno = dept.deptno

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

select ename, loc as "Location", lpad(hisal,8,'*') as "High Salaray", lpad(losal,8,'*') as "Low Salary"
from emp, dept, salgrade
where emp.deptno = dept.deptno
and (emp.sal>losal and emp.sal<hisal)
8- 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.

select sysdate as "Today Date", hiredate as "Hiring Date", round((sysdate-hiredate)/7,0) as "Total


Weeks", round(months_between(sysdate,hiredate),0) as "Total Months"

from emp
9- 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.

select ename as "Employee Names", hiredate as "Hiring Date", add_months(hiredate,8) as "8


Months Added", next_day(hiredate,'Monday') as "First
Working Week"
from emp

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.

select job as "Jobs", ename as "Employee Names", loc as "Department Location", grade as "Salaray
Grade"
from emp, dept, salgrade
where emp.deptno = dept.deptno * 10
11- Give names and salary of those employees who have ‘A’ in their names, work in department
number 10 and 20 and have salary greater than 2500.

select ename, sal, deptno


from emp
where (ename like '%A' or ename like 'A%' or ename like '%A')
and deptno in(10,20)
and sal>2500

12- Give hire date as “Original Hire Date”, hire date in format ‘22 November 2014’ as “Date Format.1”
of all employees whose commission is not null.

select hiredate as "Orignal Hire Date", to_char(hiredate,'dd monthyyyy') as "Date Format.1"


from emp
where comm is not null
13- 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 as "Employee Names", job as "Employee Job", mgr as "Supervised Manager", loc as
"Department Location", emp.deptno as "Department Number", sal as "Incremented Salary"

from emp, dept, salgrade

Вам также может понравиться