0% found this document useful (0 votes)
72 views4 pages

Practice 1 PDF

This document provides instructions and SQL queries for an employee database. It includes: 1. Instructions for a SQL programmer to create reports from the Human Resources tables at Acme Corporation, including determining the structure of the DEPARTMENTS and EMPLOYEES tables. 2. Sample queries to display information from the EMPLOYEES table like employee number, name, job, and hire date. 3. Additional optional exercises to further explore and customize the output from the EMPLOYEES table, such as modifying column headings and concatenating columns.

Uploaded by

user
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views4 pages

Practice 1 PDF

This document provides instructions and SQL queries for an employee database. It includes: 1. Instructions for a SQL programmer to create reports from the Human Resources tables at Acme Corporation, including determining the structure of the DEPARTMENTS and EMPLOYEES tables. 2. Sample queries to display information from the EMPLOYEES table like employee number, name, job, and hire date. 3. Additional optional exercises to further explore and customize the output from the EMPLOYEES table, such as modifying column headings and concatenating columns.

Uploaded by

user
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

2010

ORACLE Fundamental_ SQL 1 ‫ أ أوراآ‬

MOHAMED_SUEZ
‫إهاء إ‬
www.ARAB
/OUG/HARDWARE/TEAM2000>
3/21/2010
LES01Retrieving Data Using
the SQL SELECT Statement

PRACTIC 1:PART1

-3-The following SELECT statement executes successfully .


SELECT last_name, job_id, salary AS Sal
FROM employees;
True/False

. *+,‫ إذن ا‬%100  !"‫ ا‬#$ ‫ء ا‬#% &'#" (% :  ‫ ه ا  ام‬:3 ‫ اال‬

4. The following SELECT statement executes successfully:


SELECT *
FROM job_grades;
True/False
:" ‫ع‬+&:‫ا‬ ‫ص‬123* ‫ آن‬1‫ و‬،  5$ 56#*  7 89 ‫ل  ا‬1 ‫ اال‬1 :4 ‫ اال‬
.HR ‫د ه=ا اول *ل‬1+‫اب ? (م و‬1$

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

If you have time, complete the following exercises:


10. The HR department wants more descriptive column headings for its report on
employees. Copy the statement from lab_01_07.sql to the iSQL*Plus text box. Name
the column headings Emp #, Employee, Job, and Hire Date, respectively. Then run
your query again.
‫ن‬XI 7 ‫ال‬$ ‫م ا‬H(:\‫(ل ا‬T ‫وزة‬I HR ‫ل ان ادارة ال‬1V* :10 ‫ اال‬
‫ اال‬F*‫( و‬EMPLOYEE_ID = EMP#) ALIAS !$ ("
. !I O(:‫ ا` وا‬T M?O _9

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

Select last_name||’, ‘||job_id as “EMPLOYEE AND TITLE”


From employees;

If you want an extra challenge, complete the following exercise:


12. To familiarize yourself with the data in the EMPLOYEES table, create a query
to display all the data from that table. Separate each column output by a comma.
Name the column title THE_OUTPUT.

5%F ‫ ا‬8*‫ و‬5#* + ‫ وآ‬UF‫ ور‬Q^‫ وو‬MT&9‫ و‬U‫ ا‬5‫ آ‬hI\‫ ا‬A9 8Q^1‫ آ ا‬M:‫@ أآ‬1V* :12 ‫ اال‬
I‫( و‬,)

‫وآا ا‬Select employee_id||’,’||last_name||’,’||first_name||’,’||>>>>ETC N U‫ا‬


‫ت‬+&3‫ه=ا ا‬
.

You might also like