Examples Of In - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

The predicate expr IN (expr1, expr2, ... ) is true if and only if the following predicate
is true:
expr = ANY (expr1, expr2, ... )
IN Predicate Results
The IN predicate is true if and only if either of these is true:
The result of the row-value-constructor (a row or sequence of values) is equal to any
row of column values specified by table-subquery.
Note that a table subquery is a query expression and can be specified as a form of a simple
table; for example, as the VALUES keyword followed by a list of row values. See
Statement" (page
The result of the row-value-constructor (a single value) is equal to any of the values
specified by the list of expressions in-value-list.
In this case, it is helpful to think of the list of expressions as a one-column table—a special
case of a table subquery. The degree of the row value constructor and the degree of the list
of expressions are both one.
Comparing Character Data
Two strings are equal if all characters in the same ordinal position are equal. Lowercase and
uppercase letters are not considered equivalent. For comparisons between character strings of
different lengths, the shorter string is padded on the right with spaces (HEX 20) until it is the
length of the longer string. Both fixed-length and varying-length strings are padded in this way.
For example, Neoview SQL considers the string 'JOE' equal to a value JOE stored in a column
of data type CHAR or VARCHAR of width three or more. Similarly, Neoview SQL considers a
value JOE stored in any column of the CHAR data type equal to the value JOE stored in any
column of the VARCHAR data type.
Comparing Numeric Data
Before evaluation, all numeric values in an expression are first converted to the maximum
precision needed anywhere in the expression.
Comparing Interval Data
For comparisons of INTERVAL values, Neoview SQL first converts the intervals to a common
unit. If no common unit exists, Neoview SQL reports an error. Two INTERVAL values must be
both year-month intervals or both day-time intervals.

Examples of IN

Find those employees whose EMPNUM is 39, 337, or 452:
SELECT last_name, first_name, empnum
FROM persnl.employee
WHERE empnum IN (39, 337, 452);
LAST_NAME
--------------------
CLARK
SAFFERT
--- 2 row(s) selected.
Find those items in PARTS whose part number is not in the PARTLOC table:
SELECT partnum, partdesc
FROM sales.parts
WHERE partnum NOT IN
(SELECT partnum
FROM invent.partloc);
PARTNUM
240
SQL Language Elements
141).
FIRST_NAME
---------------
DINAH
KLAUS
PARTDESC
EMPNUM
------
337
39
"SELECT

Advertisement

Table of Contents
loading

Table of Contents