Labsheet 9
Labsheet 9
Lab sheet
Kingdo
m of
Saudi
Arabia
Minist
ry of
Higher
Educat
ion
King
Faisal
Univer
sity
College
of
Compu
ter
Science
s&
Inform
ation
Techno
logy
IS222
IS222 – DATABASE
CONCEPTS AND DESIGN
Lab sheet
IS222
Table of Contents
LAB 9: WHERE and ORDER BY............................................................................................2
Objectives:...................................................................................................................................2
Tools/Software:...........................................................................................................................2
Concepts & Descriptions:.............................................................................................................2
SELCET Statement with Order by..................................................................................................2
Examples and explanations of SELECT statement with ORDER BY................................................3
Lab Activities:...............................................................................................................................5
Deliverables:................................................................................................................................6
LAB 9: WHERE and ORDER BY
Objectives:
This lesson covers the following objectives:
Tools/Software:
To accomplish this session, students should have access to APEX.
Example Explanation
Using Logical Operators
SELECT last_name, department_id, salary In the query below, the results returned
FROM employees will be rows that satisfy BOTH
WHERE department_id > 50 AND salary > 12000; conditions specified in the WHERE
clause.
SELECT department_name, location_id The NOT operator will return rows that
FROM departments do NOT satisfy the condition in the
WHERE location_id NOT IN (1700,1800); WHERE clause.
Using Order By
SELECT last_name, hire_date uses the ORDER BY clause to order
FROM employees hire_date in ascending (default) order
ORDER BY hire_date;
1. Display the last names of all Fast Foods staff who have “e” and “i” in their last
names.
2. Display the first names and last names of all Fast Foods staff that make more than
$6.50 per hour and their position is not order taker.
3. Using the employees table, write a query to display all employees whose last names
start with “D” and have “a” and “e” anywhere in their last name.
4. Which list of operators is in the correct order from highest precedence to lowest
precedence?
1. AND, NOT, OR
2. NOT, OR, AND
3. NOT, AND, OR
5. Display all employees last names, salaries and salary*2 named Extra Credit and order
it in ascending order based the Extra Credit.
Deliverables:
At the end of this session, students are expected to:
Solve the lab activities and submit their work.