Practice 1 PDF
Practice 1 PDF
MOHAMED_SUEZ
إهاء إ
www.ARAB
/OUG/HARDWARE/TEAM2000>
3/21/2010
LES01Retrieving Data Using
the SQL SELECT Statement
PRACTIC 1:PART1
. *+, إذن ا%100 !" ا#$ ء ا#% &'#" (% : ه ا ام:3 اال
5.There are four coding errors in the following statement. Can you
identify them?
SELECT employee_id, last_name
sal x 12 ANNUAL SALARY
FROM employees;
$ 2 واG? 9HI (X) -2 ، (SAL x 12) ال%F(,) ال-1 : @ ا:* ا?ءA*ك ار# ه:5 اال
-4(SALARY) M:NO &وضQ( اHR) ب9(:" &L & وه=ا2:39 (SAL) ذآ& ال-3 (*)&بJ اI
.(“ANNUAL SALARY”) 8* (ANNUAL SALARY)( الALIAS) الARم وI
PRACTIC 1:PART2
You have been hired as a SQL programmer for Acme Corporation. Your first task is to create
some reports based on data from the Human Resources tables.
6. Your 9irst task is to determine the structure of the DEPARTMENTS table and its contents.
#%9 &OرVT ءX" إY"@ آ959 واول89W اااااااااربO ا11F SQL S9&%@ آ#(T UT F ل1VO :6 اال
OT م ه5@ اT اولY" وآO&X%ارد ا1اول ا+ I
. دارات,ء اا ول ا#%ا
&9[ ا1دارات وه,ء اا ول ا#%(&ض اO &9( ا:" ا ا\ن+ ]*
DESC DEPARTMENTs;
7. You need to determine the structure of the EMPLOYEES table.
The HR department wants a query to display the last name, job code, hire
date, and employee number for each employee, with employee number appearing
first. Provide an alias STARTDATE for the HIRE_DATE column. Save your SQL
statement to a 9ile named lab_01_07.sql so that you can disperse this 9ile to the HR
department.
DESC EMPLOYEES; ]* 8Q^1ول ا+ #* OT @#9 M?O [ول$ :7 اال
UFر ر5^ إ إ$R,* `^1 اUF ور8(: اaOرT وQ^1 اUF ا\& و رU\ ) ا8J:O مH(: إI HR & الO9 @#9 M?O : "_ا
HR ` دا ال9 $ &9\ اbQ O5#$ و8(: اaOر: (ر:9 U اI وOا%$ `^1ا
SAVE script (:م ال ه3::* 1 أوsave c: \ lab_01_07.sql &9\ اbQ#* O5#* و: V(: ا89 وOc !?* ا
Isqlplus
Select select Employee_id,last_name,job_id,hire_date as
“STARTDATE”
From from Employees;
8-Test your query in the lab_01_07.sql 9ile to ensure that it runs correctly.
ال$ 1 وM:N: هSQLPLUS ال$ Y" أ1 5 ( ال% . [ رة أم12* ( ه..... ظ1Q& ا9\& ا%: أ:8 اال
LOAD SCRIPT ر:3: هI SQLPLUS
(IF U USE SQLPLUS)>>>> RUN/@ lab_01_07.sql
9. The HR department needs a query to display all unique job codes from the
EMPLOYEES table.
89 *[ #&ار هNT ` *ون6^1 اA+ 8Q^1 اول ا89 M?* 1ه:9 اال
Select Distinct job_id &9[ام ا3:أ
DISTINCT
From employees;
PRACTIC 1:PART3
11. The HR department has requested a report of all employees and their
job IDs. Display the last name concatenated with the job ID (separated by a
comma and space) and name the column Employee and Title.
8Q^1 اA+ XO &O&VT I إدارة89 Y% ل1V* :11 اال
$9 و91(آ,) U5#* Q^1ف ا! اJ9 &[ اU[م *(&ض ا1V$ U5Q6^وو
. U5"ا1#I و8Q^1* ST# اT A9
5%F ا8* و5#* + وآUF ورQ^ ووMT&9 وU ا5 آhI\ اA9 8Q^1 آ اM:@ أآ1V* :12 اال
I( و,)