SQL/MX Report Writer Guide
Selecting Data for a Report
HP NonStop SQL/MX Report Writer Guide—527194-002
3-23
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 under Grouping Data for
Calculations on page 3-16.
You can use these arithmetic operators:
+ Addition
- Subtraction
* Multiplication
/ Division
** Exponentiation (ab)
The order of evaluation of an expression is:
1. Expressions within parentheses
2. Unary operators, plus (+) and minus (-)
3. Exponentiation
4. Multiplication and division
5. Addition and subtraction
For a complete description of expressions and syntax rules, see the SQL/MX
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 report in Figure 3-5 by
including expressions in the DETAIL command instead of the select list.
Figure 3-5. Expressions in the Select List
>> SELECT P.PARTNUM,
+> PARTCOST,
+> PARTCOST * QTY_AVAILABLE,
+> QTY_AVAILABLE * (PRICE - PARTCOST)
+> FROM SAMDBCAT.SALES.PARTS P,
+> SAMDBCAT.INVENT.PARTSUPP PS,
+> SAMDBCAT.INVENT.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