SQL/MP Reference Manual

HP NonStop SQL/MP Reference Manual523352-013
Q-6
Quantified Predicate
Quantified Predicate
A quantified predicate compares the value of an expression to all, some, or any of the
values in the result of a subquery.
Considerations—Quantified Predicate
QUANTIFIED is a comparison predicate. For a discussion of general rules for
comparisons and specific information about comparing character data (including
character data associated with collations), numeric data, date-time data, and
interval data, see Comparison Predicate on page C-58.
The subquery result must be a table of one column. The data type of the first
expression must be compatible with the data type of the subquery result column.
If you specify ALL, the predicate is true if either of this is true:
The comparison is true for every value selected by subquery.
The subquery selects no values.
If you specify ANY, the predicate is true if the comparison is true for at least one
value selected by subquery. The predicate is false if subquery selects no value,
or if the comparison is false for every value selected. SOME is a synonym for ANY.
Specifying =ANY is the same as specifying the IN predicate, although <>ANY is
not the same as NOT IN.
Examples—Quantified Predicate
This example finds all salaries that are greater than the salaries of all the
employees who have a jobcode of 420:
SALARY > ALL (SELECT SALARY
FROM EMPLOYEE WHERE JOBCODE = 420)
[ ANY ]
expression comparison-operator [ ALL ] subquery
[ SOME ]
comparison-operator is one of the following:
= Equal
<> Not equal
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to