You are on page 1of 1

connect hr;

password hr;
ASSIGNMENT 3
select first_name||last_name empname,salary monthlypay,salary*12 annualpay,e.dep
artment_id dname from employees e, departments d
where d.department_id=e.department_id order by salary;
select first_name||last_name empname,nvl(salary*commission_pct,0)+nvl(salary,0)
monthlypay,nvl(salary*12,0)+nvl(salary*commission_pct,0) annualpay,e.department_
id dname from employees e, departments d
where d.department_id=e.department_id order by salary;
select first_name||last_name empname,extract (year from sysdate)-extract (year f
rom hire_date) experience from employees order by experience;
select first_name||last_name empname,department_id deptno, nvl(salary*commission
_pct,0)+nvl(salary,0) oldsalary,nvl(salary*commission_pct,0)+nvl(salary,0)+nvl(s
alary*1.1,0) newsalary
from employees e where e.department_id=90;
select d.department_id dno,d.department_name dname,sum(salary) total from employ
ees e,departments d where e.department_id=d.department_id
group by d.department_id,d.department_name having sum(salary)>100000;
6)select e.first_name,m.first_name,e.job_id from employees e,employees m where (
e.salary,m.salary,e.job_id) in
(select max(salary),min(salary),job_id from employees group by job_id) and e.job
_id=m.job_id;
create or replace view maxminsalary(maxfname,minfname,jobid)
as
select e.first_name,m.first_name,e.job_id from employees e,employees m w
here (e.salary,m.salary,e.job_id) in
(select max(salary),min(salary),job_id from employees group by job_id) a
nd e.job_id=m.job_id
with check option;
select * from maxminsalary;
7)select e.employee_id,d.department_name,l.city,c.country_name from employees e
,departments d,locations l,countries c where e.department_id=d.department_id and
d.location_id=l.location_id and l.country_id=c.country_id;
create or replace view employeedlc(empid,departmentname,city,location)
as
select e.employee_id,d.department_name,l.city,c.country_name from employ
ees e,departments d,locations l,countries c where e.department_id=d.department_i
d and d.location_id=l.location_id and l.country_id=c.country_id
with check option;
select * from employeedlc;
8)select department_id,extract (year from hire_date) year,count(*) from
employees group by department_id,extract (year from hire_date);

You might also like