SQL/MP Report Writer Guide

Selecting Data for a Report
HP NonStop SQL/MP Report Writer Guide527213-001
3-22
Using Expressions to Calculate Report Values
An expression in the select list can refer to column names, literals, parameter names,
and aggregate functions. These functions are described in Grouping Data for
Calculations on page 3-15.
You can use the following arithmetic operators:
+ Addition
- Subtraction
* Multiplication
/ Division
** Exponentiation (ab)
The order of evaluation of an expression from first to last is:
Expressions within parentheses
Unary operators, plus (+) and minus (-
Exponentiation
Multiplication and division
Addition and subtraction
For a complete description of expressions and syntax rules, see the SQL/MP
Reference Manual.
If you are formatting a report, you can calculate column values in the select list or in a
DETAIL command. Figure 3-6 shows another way to define the previous report by
including expressions in the DETAIL command instead of the select list.
Figure 3-5. Expressions in the Select List
>> VOLUME INVENT;
>> SELECT P.PARTNUM,
+> PARTCOST,
+> PARTCOST * QTY_AVAILABLE,
+> QTY_AVAILABLE * (PRICE - PARTCOST)
+> FROM SALES.PARTS P, PARTSUPP PS, SUPPLIER S
+> WHERE P.PARTNUM = PS.PARTNUM AND PS.SUPPNUM = S.SUPPNUM;
S> LIST FIRST 1;
PARTNUM PARTCOST (EXPR) (EXPR)
212 2000.00 7050000.00 1762500.00
VST0305.vsd