SQL/MX Report Writer Guide
Selecting Data for a Report
HP NonStop SQL/MX Report Writer Guide—527194-002
3-7
Setting Criteria for Selecting Data
To select only rows describing parts with at least 50 units available, enter:
>> SELECT *
+> FROM PARTS
+> WHERE QTY_AVAILABLE >= 50;
In the next example, the WHERE clause specifies conditions for selecting rows and
specifies the method for joining three tables. Only information about local suppliers is
selected; that is, suppliers in areas with postal codes between 95400 and 95500.
>> SELECT S.SUPPNUM, SUPPNAME, P.PARTNUM,
+> QTY_AVAILABLE, PARTCOST, PRICE
+> FROM SAMDBCAT.SALES.PARTS P,
+> SAMDBCAT.INVENT.PARTSUPP PS,
+> SAMDBCAT.INVENT.SUPPLIER S
+> WHERE P.PARTNUM = PS.PARTNUM
+> AND PS.SUPPNUM = S.SUPPNUM
+> AND POSTCODE BETWEEN '95400' AND '95500';
Columns you refer to in the WHERE clause do not have to appear in the select list, but
they must be columns from one of the tables in the FROM clause.
The search condition you specify in a WHERE clause consists of predicates connected
by the Boolean operators NOT, AND, and OR. (See Specifying More Than One
Condition on page 3-14.)
Comparison predicates and quantified predicates can include these comparison
operators:
= Equal
<> Not equal
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
Table 3-1
summarizes the types of predicates you can use to express search
conditions.