Considerations For Between; Examples Of Between; Comparison Predicates - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

Considerations for BETWEEN

Logical Equivalents Using AND and OR
The predicate expr1 BETWEEN expr2 AND expr3 is true if and only if this condition is true:
expr2 <= expr1 AND expr1 <= expr3
The predicate expr1 NOT BETWEEN expr2 AND expr3 is true if and only if this condition
is true:
expr2 > expr1 OR expr1 > expr3
Descending Columns in Keys
If a clause specifies a column in a key BETWEEN expr2 and expr3, expr3 must be greater
than expr2 even if the column is specified as DESCENDING within its table definition.

Examples of BETWEEN

This predicate is true if the total price of the units in inventory is in the range from $1,000
to $10,000:
qty_on_hand * price
BETWEEN 1000.00 AND 10000.00
This predicate is true if the part cost is less than $5 or more than $800:
partcost NOT BETWEEN 5.00 AND 800.00
This BETWEEN predicate selects the part number 6400:
SELECT * FROM partsupp
WHERE partnum BETWEEN 6400 AND 6700
AND partcost > 300.00 SERIALIZABLE ACCESS;
Part/Num
--------
6400
6401
6401
--- 3 row(s) selected.
Find names between Jody Selby and Gene Wright:
(last_name, first_name) BETWEEN
('SELBY', 'JODY') AND ('WRIGHT', 'GENE')
The name Barbara Swift would meet the criteria; the name Mike Wright would not.
SELECT empnum, first_name, last_name
FROM persnl.employee
WHERE (last_name, first_name) BETWEEN
('SELBY', 'JODY') AND ('WRIGHT', 'GENE');
EMPNUM
------
43
72
74
...
--- 15 row(s) selected.

Comparison Predicates

"Considerations for Comparison Predicates"
"Examples of Comparison Predicates"
A comparison predicate compares the values of sequences of expressions, or the values of
sequences of row values that are the result of row subqueries.
234
SQL Language Elements
Supp/Num
Part/Cost
--------
------------
1
2
3
FIRST_NAME
LAST_NAME
---------------
--------------------
PAUL
WINTER
GLENN
THOMAS
JOHN
WALKER
Qty/Rec
----------
390.00
50
500.00
20
480.00
38

Advertisement

Table of Contents
loading

Table of Contents