You are on page 1of 31

Logical Operators

After completing this module, you will be able to:

Use Logical Operators in writing queries.


Link Logical Operators together with AND OR BETWEEN IN and
NOT IN.
Identify unsatisfiable conditions.
Use parentheses to show order of precedence and improve
readability.
Incorporate NULL syntax into queries correctly.
Identify issues introduced by adding NULL into WHERE conditions.

Logical Operators Introduction

The comparison operators that we will be studying in this module are


shown below. The symbols are ANSI standard. The abbreviations are
Teradata extensions.

Comparison Operators
(alternative abbreviations included where applicable):

= (EQ) Equal
< > (NE) Not equal
Discussed > (GT) Greater than
earlier. < (LT) Less than
> = (GE) Greater than or equal to
< = (LE) Less than or equal to
BETWEEN. . . AND Inclusive range
[NOT] IN Test against predefined set
IS [NOT] NULL Test for nulls

The AND Condition

Retrieve all employees with last name of Brown. Employee Table


Last First Dept#
SELECT Last_Name, First_Name, Dept# Name Name
FROM Employee
WHERE Last_Name = 'brown'; Brown Alan 401

last_name first_name dept# Brown Allen 801


---------- ---------- -----------
Brown Cary 567
Brown Alan 401
Brown Allen 801 Smith Mary 900
Brown Cary 567
Jones Jimmy 401

Retrieve information for employee Alan Brown.

SELECT Last_Name, First_Name, Dept#


FROM Employee
WHERE Last_Name = 'brown' All conditions linked with AND
AND First_Name = 'alan'; must evaluate True in the
same row for the predicate to
last_name first_name dept# evaluate True.
---------- ---------- -----------
Brown Alan 401

The OR Condition

Employee Table
Contrast the AND with the OR, below:
Last First Dept#
Name Name
Retrieve employees with last name Brown
and first name Mary. Brown Alan 401

SELECT * Brown Allen 801

FROM Employee Brown Cary 567


WHERE Last_Name = 'brown'
Smith Mary 900
AND First_Name = 'mary';
Jones Jimmy 401
*** Query completed. No rows found.

Retrieve employees with last name Brown


or first name Mary.
last_name first_name dept#
SELECT * ---------- ---------- -----------
FROM Employee Smith Mary 900
WHERE Last_Name = 'brown' Brown Alan 401
OR First_Name = 'mary'; Brown Allen 801
Brown Cary 567

Mixing AND and OR

Contrast the 2 queries below. Employee Table


Last First Dept#
Retrieve employees with last name Brown Name Name

and work in department 401.


Brown Alan 401
SELECT *
FROM Employee Brown Allen 801

WHERE Last_Name = 'brown' Brown Cary 567


AND Dept# = 401;
Smith Mary 900
last_name first_name dept#
Jones Jimmy 401
---------- ---------- -----------
Brown Alan 401

Retrieve employees with last name Brown and Work in department 401, OR first
name Mary. (AND is evaluated first)
SELECT *
last_name first_name dept#
FROM Employee
---------- ---------- -----------
WHERE Last_Name = 'brown' Smith Mary 900
AND Dept# = 401 Brown Alan 401
OR First_Name = 'mary';

Parentheses and the Predicate

The use of the parentheses in this query illustrate the order of evaluation of AND and OR for
the query on the previous page.

Retrieve employees with SELECT * Employee Table


last name Brown and FROM Employee Last First Dept#
work in department 401, WHERE (Last_Name = 'brown' Name Name
or first name is Mary. AND Dept# = 401)
OR (First_Name = 'mary'); Brown Alan 401

Brown Allen 801


last_name first_name dept#
---------- ---------- ----------- Brown Cary 567
Smith Mary 900
Brown Alan 401 Smith Mary 900

Jones Jimmy 401


Rearranging the parentheses changes the business question.

Retrieve employees with last name of Brown,


AND first name of Mary or work in department 401.

SELECT *
FROM Employee last_name first_name dept#
WHERE (Last_Name = 'brown') ---------- ---------- -----------
AND (Dept# = 401 Brown Alan 401
OR First_Name = 'mary');

The IN Operator

Retrieve employee whose first names are in the following Employee Table
list (as a set). Last First Dept#
Name Name

SELECT *
FROM Employee Brown Alan 401

WHERE First_Name IN ('alan', 'allen'); Brown Allen 801

Brown Cary 567


last_name first_name dept#
---------- ---------- ----------- Smith Mary 900
Brown Alan 401
Brown Allen 801 Jones Jimmy 401

Submitting the request by prefixing it with the EXPLAIN keyword will yield the optimizer
rewrite of this query (see left hand page). Here it reveals an alternate and equivalent syntax.

. . . . Rewrite Equivalent:
3) We do an all-AMPs RETRIEVE step from DLM.Employee by way of an
WHERE
all-rows scan with a condition of ("(DLM.Employee.first_name =
First_Name = 'allen'
'allen') OR (DLM.Employee.first_name = 'alan')") into Spool 1
OR
(group_amps), which is built locally on the AMPs. The size of
First_Name = 'alan';
Spool 1 is estimated with no confidence to be 7 rows (595 bytes).
The estimated time for this step is 0.02 seconds.
. . . .

The NOT IN Operator

Retrieve employee whose first names are NOT IN the Employee Table
following list (as a set).
Last First Dept#
Name Name
SELECT *
FROM Employee Brown Alan 401
WHERE First_Name NOT IN ('alan', 'allen');
Brown Allen 801
last_name first_name dept#
Brown Cary 567
---------- ---------- -----------
Brown Cary 567 Smith Mary 900
Smith Mary 900
Jones Jimmy 401
Jones Jimmy 401

Submitting the request by prefixing it with the EXPLAIN keyword will yield the optimizer
rewrite of this query (see left hand page). Here it reveals an alternate and equivalent syntax.

. . . . Rewrite Equivalent:
3) We do an all-AMPs RETRIEVE step from DLM.Employee by way
of an all-rows scan with a condition of (DLM.Employee.first_name WHERE
<> 'alan') AND (DLM.Employee.first_name <> 'allen')") into Spool 1 First_Name <> 'allen'
(group_amps), which is built locally on the AMPs. The size of AND
Spool 1 is estimated with no confidence to be 20 rows (1,700 First_Name <> 'alan';
bytes). The estimated time for this step is 0.02 seconds.
. . . .

Exclusive OR

An exclusive OR is where we want one condition or the other condition to be true,


but not both to be true.
SELECT * Typical OR. Employee Table
FROM Employee Last First Dept#
WHERE Last_Name = 'Brown' Name Name
OR First_Name = 'Alan'
Adams Alan 401
last_name first_name dept#
Brown Allen 801
---------- ---------- -----------
Brown Allen 801 Murphy Cary 567
Brown Alan 301
Adams Alan 401 Blair Mary 900

Brown Alan 301

SELECT * The XOR.


FROM Employee Exclusive OR result
WHERE (Last_Name = 'Brown'
last_name first_name dept#
AND First_Name <> 'Alan') ---------- ---------- -----------
OR Brown Allen 801
(Last_Name <> 'Brown' Adams Alan 401
AND First_Name = 'Alan');
(Note: Alan Brown does not appear in this result as he did in
the previous result.)

The BETWEEN Operator

You can use BETWEEN to perform range constraints.


BETWEEN is inclusive, as can be seen in the optimizer Employee Table
rewrite. Last First Dept#
Name Name

SELECT *
Brown Alan 401
FROM Employee
WHERE Dept# BETWEEN 401 and 567; Brown Allen 801

Brown ? 567
last_name first_name dept#
---------- ---------- ----------- Smith Mary ?
Jones Jimmy 401
Jones Jimmy 401
Brown Alan 401
Brown ? 567

Explanation
---------------------------------------------------------------------------------------------------------------------------------------
. . . .
3) We do an all-AMPs RETRIEVE step from customer_service.Employee by way of an all-rows
scan with a condition of ("(customer_service.Employee.dept# <= 567) AND
(customer_service.Employee.dept# >= 401)") into Spool 1 (group_amps), which is built
locally on the AMPs. The size of Spool 1 is estimated with no confidence to be 4 rows (340
bytes). The estimated time for this step is 0.02 seconds.
. . . .

NULL

NULL represents something of unknown quantity or value.


NULL is an SQL keyword.
NULL is neither a data type nor a characteristic of data.
When doing an ascending sort, NULLs sort before numbers and characters
(including spaces and zeroes).

Any arithmetic operation involving a NULL operand (literal, column, or expression)


computes a NULL result.

Col_A [ + - * / ] Col_B = NULL

Any logical conditional expression involving a NULL operand (literal, column, or


expression) evaluates as unknown (Not True AND Not False).

Col_A [ >, >=, <, <=, =, <> ] Col_B result is unknown

Although you can set the displayed value for NULL in both BTEQ and SQL
Assistant, the default value is to display a ? (question mark).

Conditional Expressions and NULL

Conditional expressions may involve columns or literals.

Checking whether a column IS, or IS NOT, NULL:


WHERE Salary = NULL -- Incorrect Usage
WHERE Salary = '' -- (two single quotes) - Incorrect Usage
WHERE Salary NOT= NULL -- Incorrect Usage
WHERE Salary <> NULL -- Incorrect Usage

WHERE Salary IS NULL -- Correct Usage


WHERE Salary IS NOT NULL -- Correct Usage
Comparing two columns, either of which may contain a null.
WHERE Old_Salary [ operator ] New_Salary

Logically and semantically, there is a subtle, but distinct, difference between:


Comparing two columns, where one or both contain a null. (e.g., WHERE Col1 = Col2)
Asking if a column or expression result is null. (i.e., WHERE Col1 IS NULL)

What Gets Returned

In SQL, the database only projects column values for those rows that contain data
that satisfy all of the WHERE CONDITIONS.
If columns for a row are not projected, it is not because the conditions evaluated
FALSE, but instead because they did not evaluate TRUE.
We will build on this logic throughout the course.

Observe:

For this C1 The following T/F/Unknown evaluations occur.


value:
WHERE C1 = 'X' T (row projected)
X WHERE C1 = 'Y' F (row not projected)
WHERE C1 = NULL Unknown (row not projected)

WHERE C1 <> 'X' F (row not projected)


WHERE C1 <> 'Y' T (row projected)
WHERE C1 <> NULL Unknown (row not projected)

NULL and the Business Question

Retrieve employees whose first


name is not known. Note the Employee Table
addition of Last First Dept#
SELECT * two nulls in Name Name
FROM Employee the table!
WHERE First_Name IS NULL; Brown Alan 401

Brown Allen 801


last_name first_name dept#
---------- ---------- ----------- Brown ? 567
Brown ? 567
Smith Mary ?

Retrieve employees whose first name is unknown, Jones Jimmy 401


or work in department numbers less than 500.

SELECT *
FROM Employee
WHERE Dept# < 500 SELECT *
OR First_Name IS NULL; FROM Employee
WHERE Dept# = NULL;
last_name first_name dept#
---------- ---------- ----------- *** Failure 3731 The user must use IS
Jones Jimmy 401 NULL or IS NOT NULL to test for NULL
Brown Alan 401 values.
Brown ? 567

NOT NULL and the Business Question

Retrieve all employees who have first names.


Employee Table
Last First Dept#
SELECT * Name Name
FROM Employee
WHERE First_Name IS NOT NULL; Brown Alan 401

Brown Allen 801


last_name first_name dept#
---------- ---------- ----------- Brown ? 567
Smith Mary ?
Smith Mary ?
Brown Alan 401
Jones Jimmy 401 Jones Jimmy 401
Brown Allen 801

SELECT *
FROM Employee
WHERE First_Name <> NULL;

*** Failure 3731 The user must use IS NULL or IS NOT NULL to test for NULL values.

Negating Conditions and Operators

To retrieve employees other than those in department number 401,


you can perform either of the following:

Negate the operator - Employee Table


SELECT * Last First Dept#
NE
Name Name = 401
FROM Employee 401
WHERE Dept# <> 401 Brown Alan 401 T F Not True
Or negate the condition - Brown Allen 801 T
F
SELECT * Brown ? 567 F T
FROM Employee
Smith Mary ? ? ? Not True
WHERE NOT (Dept# = 401);
Jones Jimmy 401 T F Not True

last_name first_name dept#


---------- ---------- -----------
Brown Allen 801
Brown ? 567

The IN Operator and NULL

Retrieve employees whose first names are in the following list (as a set).

SELECT * Employee Table


FROM Employee Last First Dept#
WHERE First_Name IN ('alan', 'allen'); Name Name =

The rewrite of this query shows an


Brown Alan 401 T
alternate method for writing this. Brown Allen 801 T
Brown ? 567 ? Not True
last_name first_name dept#
---------- ---------- -----------
Smith Mary ? F Not True
Brown Alan 401 Jones Jimmy 401 F Not True
Brown Allen 801

. . . .
3) We do an all-AMPs RETRIEVE step from DLM.Employee by way of an
EXPLAIN
all-rows scan with a condition of ("(DLM.Employee.first_name =
SELECT *
'allen') OR (DLM.Employee.first_name = 'alan')") into Spool 1
FROM Employee
(group_amps), which is built locally on the AMPs. The size of
WHERE First_Name
Spool 1 is estimated with no confidence to be 7 rows (595 bytes).
IN ('alan', 'allen');
The estimated time for this step is 0.02 seconds.
. . . .

The NOT IN Operator and NULL

Retrieve employee whose first names are NOT IN the


following list (as a set).
Employee Table
Last First Dept#
SELECT * Name Name NOT
IN (IN)
FROM Employee
WHERE First_Name NOT IN ('alan', 'allen'); Brown Alan 401 T F Not True
Brown Allen 801
T F Not True
last_name first_name dept# Brown ? 567
? ? Not True
---------- ---------- -----------
Smith Mary ? Smith Mary ? F T
Jones Jimmy 401 Jones Jimmy 401 F T

The EXPLAIN of this query shows an alternate method for writing this.

. . . .
3) We do an all-AMPs RETRIEVE step from DLM.Employee by way
of an all-rows scan with a condition of (DLM.Employee.first_name
<> 'alan') AND (DLM.Employee.first_name <> 'allen')") into Spool 1
(group_amps), which is built locally on the AMPs. The size of
Spool 1 is estimated with no confidence to be 20 rows (1,700
bytes). The estimated time for this step is 0.02 seconds.
. . . .

<> With OR vs. <> With AND

Contrast the previous (NOT IN) query result against these two query results.

SELECT * Employee Table


FROM Employee
Last First Dept#
WHERE First_Name <> 'alan'
AND First_Name <> 'allen';
Name Name OR AND

Brown Alan 401 T F Not True


last_name first_name dept#
Brown Allen 801 T F Not True
---------- ---------- -----------
Smith Mary ? Brown ? 567 ? ? Not True
Jones Jimmy 401
Smith Mary ? T T
SELECT * Jones Jimmy 401 T T
FROM Employee
WHERE First_Name <> 'alan'
OR First_Name <> 'allen';
Remember that when using OR, if only
one condition evaluates TRUE, the
last_name first_name dept#
predicate evaluates TRUE!
---------- ---------- -----------
Smith Mary ?
For the bottom query, this means:
Brown Alan 401
For Alan Brown Alan <> Allen
Jones Jimmy 401
For Allen Brown Allen <> Alan
Brown Allen 801

NULL Literal in an IN-List

Recall the difference between comparing two columns


where one or both may contain a null, (e.g., WHERE Col1 Employee Table
= Col2) vs. asking if a column or expression is null (i.e., Last First Dept#
WHERE Col1 IS NULL). Name Name

SELECT * Brown Alan 401

FROM Employee Brown Allen 801


WHERE Dept# IN (401, 403, null);
Brown ? 567

last_name first_name dept# Not included in


Smith Mary ?
---------- ---------- ----------- the result.
Jones Jimmy 401 Jones Jimmy 401
Brown Alan 401

Explanation
-------------------------------------------------------------------------------------------------
The EXPLAIN shows how
. . . .
the database correctly
3) We do an all-AMPs RETRIEVE step from DLM.Employee by way
treats the NULL literal as a
of an all-rows scan with a condition of (
comparison.
"(DLM.Employee.dept# = 403) OR
((DLM.Employee.dept# = 401) OR
(DLM.Employee.dept# = NULL ))")
into Spool 1 (group_amps), which is built locally on the AMPs.
The size of Spool 1 is estimated with no confidence to be 4

Including NULL to an IN-List

Note the difference between this EXPLAIN and that for the
query on the previous page. Employee Table
Last First Dept#
SELECT * Name Name
FROM Employee
WHERE Dept# IS NULL Brown Alan 401
OR Dept# IN (401, 403);
Brown Allen 801

last_name first_name dept# Brown ? 567


---------- ---------- -----------
Smith Mary ? Smith Mary ?
Brown Alan 401
Jones Jimmy 401
Jones Jimmy 401

Explanation
---------------------------------------------------------------------------------------------------------------------
. . . .
3) We do an all-AMPs RETRIEVE step from DLM.Employee by way of an
all-rows scan with a condition of (
"(DLM.Employee.department_number = 403) OR
((DLM.Employee.department_number = 401) OR
(DLM.Employee.department_number IS NULL ))") Note: IS NULL
into Spool 1 (group_amps), which is built locally on the AMPs.
The size of Spool 1 is estimated with no confidence to be 9 rows (1,323 bytes).

NULL Literal in a NOT IN-List

This page is the reason for the immediately preceding pages.


No rows are returned due to the result of everything being
linked with AND together with the outlined condition never
being able to be true. Employee Table
Last First Dept#
SELECT * Name Name

FROM Employee
Brown Alan 401
WHERE Dept# NOT IN (401, 403, null);
Brown Allen 801

*** Query completed. No rows found. Brown ? 567

Smith Mary ?
The EXPLAIN shows how the database correctly treats the NULL
literal as a comparison. Jones Jimmy 401

Explanation
---------------------------------------------------------------------------------------------------------------------------------------------
. . . .
3) We do an all-AMPs RETRIEVE step from DLM.Employee by way of an all-rows scan with a
condition of ("(DLM.Employee.dept# <> NULL) AND ((DLM.Employee.dept# <> 401) AND
DLM.Employee.dept# <> 403 ))") into Spool 1 (group_amps), which is built locally on the AMPs.
. . . .

Three Versions of NOT IN

The following 3 queries return the same result.

SELECT * SELECT *
FROM Employee FROM Employee
WHERE First_Name NOT IN ('alan', 'allen'); WHERE First_Name <> 'alan'
AND First_Name <> 'allen';
SELECT *
FROM Employee
WHERE NOT (First_Name = 'alan' All three return the explain
OR First_Name = 'allen'); shown below.

Explanation
---------------------------------------------------------------------------
. . .
3) We do an all-AMPs RETRIEVE step from DLM.Employee by way of an
all-rows scan with a condition of ("(DLM.Employee.first_name <>
'allen ') AND (DLM.Employee.first_name <> 'alan ')") into Spool 1
(group_amps), which is built locally on the AMPs. The size of
Spool 1 is estimated with no confidence to be 10 rows (520 bytes).
The estimated time for this step is 0.02 seconds.
. . .

Incorrect Sequencing of the BETWEEN

Contrast this query with the one following it:


Employee Table
SELECT * Last First Dept#
FROM Employee Name Name
WHERE Dept# BETWEEN 567 AND 401;
Brown Alan 401

The optimizer rewrites the previous query to the Brown Allen 801
following.
Brown ? 567

How many rows can satisfy this condition? Smith Mary ?

Jones Jimmy 401


SELECT *
FROM Employee
WHERE Dept# >= 567
AND Dept# <= 401;

This condition is deemed unsatisfiable by the optimizer.


This is not a failure!

*** Query completed. No rows found.



Explaining the Incorrect Sequencing of
BETWEEN

The EXPLAIN of the previous query illustrates how the Employee Table
optimizer is aware of the unsatisfiable condition. Last First Dept#
Name Name
Only a quick PI access is attempted with an
unsatisfiable condition. Brown Alan 401

The optimizer never estimates 0 rows, so the EXPLAIN Brown Allen 801
showing the 1 row can be ignored. Brown ? 567

Smith Mary ?
SELECT *
FROM Employee Jones Jimmy 401

WHERE Dept# BETWEEN 567 AND 401;

Explanation
----------------------------------------------------------------------------------------------------------------------------------------------
1) First, we do a single-AMP RETRIEVE step from DLM.Employee by way of the primary index
"DLM.Employee.last_name = _LATIN '010000001800000001E0'XC" with unsatisfiable conditions
into Spool 1 (one-amp), which is built locally on that AMP. The size of Spool 1 is estimated with
high confidence to be 1 row (52 bytes). The estimated time for this step is 0.00 seconds.
-> The contents of Spool 1 are sent back to the user as the result of statement 1. The total
estimated time is 0.00 seconds..

Unsatisfiable BETWEEN with AND
Residual

Employee Table
Since all AND'ed conditions must evaluate true for
Last First Dept#
projection, this condition is also unsatisfiable. Name Name

Brown Alan 401


SELECT *
FROM Employee Brown Allen 801

WHERE Dept# BETWEEN 567 AND 401 Brown ? 567


AND Last_Name = 'brown';
Smith Mary ?

*** Query completed. No rows found. Jones Jimmy 401

Explanation
---------------------------------------------------------------------------
1) First, we do a single-AMP RETRIEVE step from DLM.Employee by way
of the primary index "DLM.Employee.last_name = _LATIN
'01000000180000000180'XC" with unsatisfiable conditions into Spool
1 (one-amp), which is built locally on that AMP. The size of
Spool 1 is estimated with high confidence to be 1 row (52 bytes).
The estimated time for this step is 0.00 seconds.
-> The contents of Spool 1 are sent back to the user as the result of
statement 1. The total estimated time is 0.00 seconds.

Unsatisfiable BETWEEN with OR
Residual
Unsatisfiable conditions combined with OR need
only satisfy the OR condition. Employee Table
SELECT * Last First Dept#
Name Name
FROM Employee
WHERE Dept# BETWEEN 567 AND 401
OR Last_Name = 'brown'; Brown Alan 401

Brown Allen 801


last_name first_name dept#
Brown ? 567
---------- ---------- -----------
Brown Alan 401 Smith Mary ?
Brown Allen 801
Brown ? 567 Jones Jimmy 401

Explanation
-------------------------------------------------------------------------------------------------------------------------
. . . . . . .
3) We do an all-AMPs RETRIEVE step from DLM.Employee by way of an all-rows scan with a
condition of ("DLM.Employee.last_name = 'brown '") into Spool 1 (group_amps), which is built
locally on the AMPs. The size of Spool 1 is estimated with no confidence to be 4 rows (340
bytes). The estimated time for this step is 0.02 seconds.
4) Finally, we send out an END TRANSACTION step to all AMPs involved in processing the
request.
-> The contents of Spool 1 are sent back to the user as the result of statement 1. The total
estimated time is 0.02 seconds.

Precedence of Operators

The following is the order of precedence for predicates (WHERE conditions).

Evaluation Precedence:
1. Parenthesis evaluated first
2. NOT operators
3. AND operators
4. OR operators
5. Operators of equal precedence evaluated from left to right

SELECT Last_Name, Salary_Amount, SELECT Last_Name, Salary_Amount,


Manager_Employee_Number, Manager_Employee_Number,
Job_Code, Department_Number Job_Code, Department_Number
FROM Employee FROM Employee
With
WHERE WHERE
Parentheses
Manager_Employee_Number (Manager_Employee_Number NOT IN
NOT IN (1011, 801, 1017, 1019, 1005, 1003) (1011, 801, 1017, 1019, 1005, 1003))
OR Salary_Amount OR (Salary_Amount
BETWEEN 10000 AND 20000 BETWEEN 10000 AND 20000
AND Department_Number IN (301, 401) AND Department_Number IN (301, 401))
OR Job_Code IN (111100, 211100) OR (Job_Code IN (111100, 211100))

Module 3: Summary

Operators =, <>, <=, >=, <, >, IN, NOT IN and BETWEEN can be used as
qualifiers.
All conditions found of the WHERE clause must be satisfied for results
to be projected.
All AND'ed conditions in a list must evaluate true.
Only one condition of an OR'ed list need evaluate true.
Parentheses can be used to (reorder an) order of operations.
NULL, when used in a condition, evaluates unknown.
An EXPLAIN of a query can reveal the optimizer's rewrite and provide a
better understanding of the query.
BETWEEN is inclusive when used to qualify on a range of values.
IN, and NOT IN lists can be used as a short cut to replace long
AND/OR linked conditions.

Module 3: Review Questions

True or False:

1. The IN operator is a short-cut for replacing a list of OR'ed conditions.


True
2. When using BETWEEN, only numeric data may be compared.
False character data values may be compared as well
3. A NULL is treated like a zero (0) or a space(' ').
False
4. Unsatisfiable conditions are those which can never be true.
True
5. The following are equivalent operator conditions. C1 > 500 vs. C1 >= 501
True but only if C1 is an integer
6. You can include NULL inside an IN or NOT IN list
True but it may not return the desired result
7. The items inside an IN list must be in order from lowest to highest.
False

Module 3: Lab Exercise

1) List last names, department numbers for employee in department 301, 401,
and 501.

2) Project the last names of employees whose salary is greater than or equal
to $28,078.

3) Request a report of employees who have not been assigned to a


department.

4) Modify #1 to include those employee who have a job code of either


512102, 432101.

5) Modify #4 to show only those whose salary amounts are between $50,000
and $60,000.

6) Although we only discussed less than in this module, project a distinct


list of job codes which have been assigned to people and are greater than
510000 and sort the result descending.

You might also like