SOME
Synopsis
scalar-expression comparison-operator SOME (subquery)
Arguments
scalar-expression | A scalar expression (most commonly a data column) whose values are being compared with the result set generated by subquery. |
comparison-operator | One of the following comparison operators: = (equal to), <> or != (not equal to), < (less than), <= (less than or equal to), > (greater than), >= (greater than or equal to), [ (contains), or ] (follows). |
subquery | A subquery, enclosed in parentheses, which returns a result set that is used for the comparison with scalar-expression. |
Description
The SOME keyword works in conjunction with a comparison operator to create a predicate (a quantified comparison condition) that is true if the value of a scalar expression matches one or more of the corresponding values retrieved by the subquery. The SOME predicate compares a single scalar-expression item with a single subquery SELECT item. A subquery with more than one select item generates an SQLCODE -10 error.
The SOME and ANY keywords are synonyms.
SOME can be used wherever a predicate condition can be specified, as described in the Overview of Predicates page of this manual.
Example
The following example selects those employees with salaries greater than $75,000 that live in any of the states west of the Mississippi River:
SELECT Name,Salary,Home_State FROM Sample.Employee
WHERE Salary > 75000
AND Home_State = SOME
(SELECT State FROM Sample.USZipCode
WHERE Longitude < -93)
ORDER BY Home_State