Professional Documents
Culture Documents
Practice 7 PDF
Practice 7 PDF
Moh&Ali
إهاء إWWW.ARAB
/OUG/HARDWARE/TEAM2000
3/21/2010
LES 07 Using the Set Operators
Pracce 7:
1.The HR department needs a list of department IDs for departments that do not contain the
job ID ST_CLERK. Use set operators to create this report.
وز ارم ادارات دارات ا:1 اال
!"# ه# هST_CLERCK ى و
ول%& '( *ط+ ا,- './ و0!ول ا%1Union
.ادارات
select department_id
from departments
Union
select department_id
from employees
where job_id<>'ST_CLERCK';
2. The HR department needs a list of countries that have no departments located in them. Display
the country ID and the name of the countries. Use set operators to create this report.
د3 و4- ش إدارات4( د ا78"*ض ا3 وز:2 اال
4? وا<د ا;ص%8*ض ا>= ا
SQL> select country_id,country_name (رًاB"- ?&C اDB هE 0( FG= ا3 =)).
2 from countries
3 where country_id in (select country_id
4 from countries
5 minus select country_id
6 from locations);
CO COUNTRY_NAME
-- ----------------------------------------
AR Argentina
BE Belgium
DK Denmark
EG Egypt
FR France
HK HongKong
IL Israel
KW Kuwait
NG Nigeria
ZM Zambia
ZW Zimbabwe
3.Produce a list of jobs for departments 10, 50, and 20, in that order. Display job ID and
department ID using set operators.
'( *ح < وP #"! ه#(ه50/20/10) ادارات- 4? 'G وأرم ادارات اJK ا*ض ا>!ء ا:3 اال
اG ول ادارات%1- Q( < أن+( #4&ول ادارات وها%& 0( =4*S/ 0!ول ا%& 0( 4 ر= ادارة
.(Dummy) رغ- !د,/<( '.#-
select job_id,department_id
from employees
where department_id in (10,20,50)
minus
select to_char(null),department_id
from departments;
4.Create a report that lists the employee IDs and job IDs of those employees who currently have a job
title that is the same as their job title when they were initially hired by the company (that is, they
changed jobs but have now gone back to doing their original job).
=V =4#4( *تW *آ اى+? 4? أو%? = ا4#4( Y#- ا ?"!ا0! اJK وز ارم وو:4 اال
.INTERSECT 'PG ا,- م%;3 اB4- *اZ (*ة ا4 دو
select employee_id,job_id
from employees
intersect
select employee_id,job_id
from job_history;
5. The HR department needs a report with the following specifications:
A-Last name and department ID of all the employees from the EMPLOYEES table, regardless of
whether or not they belong to a department
B- Department ID and department name of all the departments from the DEPARTMENTS table,
regardless of whether or not they have employees working in them
select last_name,department_id,to_char(null)
from employees
union all
select to_char(null),department_id,department_name
from departments