Professional Documents
Culture Documents
IS222 – DATABASE
CONCEPTS AND DESIGN
Lab sheet
Lab 9: WHERE and ORDER BY
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:..............................................................................................................................7
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.
SELECT Last_Name
FROM F_Staffs
WHERE Last_Name LIKE '%e%' AND Last_Name LIKE '%i%';
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.
SELECT *
FROM employees
WHERE LAST_NAME LIKE 'D%'
AND LAST_NAME LIKE '%a%'
AND LAST_NAME LIKE '%e%';
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
The correct order of operators from highest precedence to lowest
precedence is: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.