Examples Of Comparison Predicates - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

Predicate X>=Y is true if X>Y is true or X=Y is true. In this scenario, Neoview SQL might look
through all components and return true if they are all equal. It stops at the first nonequal
components, Xm<>Ym. If Xm>Ym, the predicate is true. Otherwise, it is false.
Predicate X<Y is true if for some index m Xm<Ym, and for all i=1,..,m-1: Xi=Yi. Neoview
SQL does not look through all components. It stops when it finds the first nonequal components
Xm<>Ym. If Xm<Ym, the predicate is true. Otherwise, the predicate is false. The predicate is also
false if all components are equal, or X=Y.
Predicate X<=Y is true if X<Y is true or X=Y is true. In this scenario, Neoview SQL might need to
look through all components and return true if they are all equal. It stops at the first nonequal
components, Xm<>Ym. If Xm<Ym, the predicate is true. Otherwise, it is false.
Comparing Character Data
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
variable-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.
Two strings are equal if all characters in the same ordinal position are equal. Lowercase and
uppercase letters are not considered equivalent.
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.
Comparing Multiple Values
Use multivalue predicates whenever possible; they are generally more efficient than equivalent
conditions without multivalue predicates.

Examples of Comparison Predicates

This predicate is true if the customer number is equal to 3210:
custnum = 3210
This predicate is true if the salary is greater than the average salary of all employees:
salary >
(SELECT AVG (salary) FROM persnl.employee);
This predicate is true if the customer name is BACIGALUPI:
custname = 'BACIGALUPI'
This predicate evaluates to unknown for any rows in either CUSTOMER or ORDERS that
contain null in the CUSTNUM column:
customer.custnum > orders.custnum
This predicate returns information about anyone whose name follows MOSS, DUNCAN in
a list arranged alphabetically by last name and, for the same last name, alphabetically by
first name:
(last_name, first_name) > ('MOSS', 'DUNCAN')
REEVES, ANNE meets this criteria, but MOSS, ANNE does not.
This multivalue predicate is equivalent to this condition with three comparison predicates:
236
SQL Language Elements

Advertisement

Table of Contents
loading

Table of Contents