SQL/MP Report Writer Guide

Selecting Data for a Report
HP NonStop SQL/MP Report Writer Guide527213-001
3-10
Developing a Query
To confirm the result of the previous query, you can select the PARTLOC information
for the two parts. The QTY_ON_HAND value is greater than 500 in at least one
location.
>> SELECT * FROM INVENT.PARTLOC
+> WHERE PARTNUM IN ( 2001, 2403 );
S> LIST ALL;
LOC_CODE PARTNUM QTY_ON_HAND
-------- ------- -----------
A10 2001 800
A88 2403 735
G88 2403 32
P10 2001 0
--- 4 row(s) selected.
Comparing a Set of Columns to a Set of Values
You can use comparison and BETWEEN predicates to select rows based on values
from more than one column in the row when the data types of the expressions are
compatible. For example, you might want to select a range of rows from a list of names
by examining both the first and last names. In the EMPLOYEE table, these names are
stored in separate columns.
The following query selects employee numbers and job codes for all employees whose
names are between CLARK, LARRY and FOLEY, MARK:
>> SELECT EMPNUM, JOBCODE
+> FROM PERSNL.EMPLOYEE
+> WHERE LAST_NAME, FIRST_NAME BETWEEN "CLARK", "LARRY"
+> AND "FOLEY", "MARK";
The names CLARK, JUNE and FOLEY, MAVA would not be selected.
The following query selects a customer located at 2300 BROWN BLVD in FRESNO,
CALIFORNIA:
>> SELECT CUSTNUM, CUSTNAME
+> FROM SALES.CUSTOMER
+> WHERE STREET = "2300 BROWN BLVD" AND
+> CITY = "FRESNO" AND
+> STATE = "CALIFORNIA";
You can simplify this query as follows:
>> SELECT CUSTNUM, CUSTNAME
+> FROM SALES.CUSTOMER