In this step, you see how to create a temporary result mathematical calculation involving data contained in the database.
Concepts
These are the major concepts related to this step:
SET
A verb in a DQL statement that defines a temporary result for calculation results and reporting.
Result
You must give the temporary result a unique name, that is, any 1- to 32-character name which is not the same as another result or a column within the tables your query is searching. You can use the temporary results name in other calculations within your query. For example, you can use one SET statement to add numeric data contained in two columns. You can use a second SET statement to multiply the first result by a numeric literal to obtain a percentage of the first result. Another possibility is using one SET statement to do both of the above operations. In this case, you would be building a more complex arithmetic expression.
Precision (n.d.)
Refers to the number of positions in the temporary result before the decimal point, N, and after the decimal point, D. You must specify a precision that will contain the largest possible result from the calculation. The default is (10.5). Whatever precision you specify, the total of n and d cannot exceed 18, and the precision must be enclosed in parentheses. If you do not want any digits displayed after the decimal point, make d equal to 0.
Equal sign (=)
Tells CA Dataquery that the mathematical expression following this sign will define the calculations for the temporary result.
Numeric-column-name
Columns or other temporary results used in the calculation must contain numeric data.
Arithmetic-expression
Your expression can specify one or more arithmetic operations to perform on the selected data. The following chart describes the arithmetic functions you can use.
|
Function |
Operator |
Description |
|---|---|---|
|
Add |
+ |
Adds the specified numeric data. |
|
Subtract |
- |
Subtracts the specified numeric data. |
|
Divide |
/ |
Divides the specified numeric data (divisor cannot be 0). |
|
Multiply |
* |
Multiplies the specified numeric data (multiplier cannot be 0). |
|
Parenthetical expression |
( ) |
Use to clarify which operations are to be performed first in a complex calculation (can specify up to 5 levels of nested expressions). |
Numeric-literal
You can assign the temporary result a numeric literal value. You can also use numeric literals alone or in combination with data from columns to build arithmetic expressions to calculate a value for the temporary result.
Procedure
The last step specified conditions for the query's search for data. Following is an example of how the query looks now.
=> --------------------------------------------------------------------------DQD10 DATAQUERY: EDITOR CURRENT TABLE: CAI-DETAIL-TBL ------------------------------------------------------------------------------- NAME: USER-SAMPLE TYPE: QUERY STATUS: PRIVATE DESCRIPTION: TOTAL ORDERS PER CUSTOMER -- AVERAGE PRICE ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+. .. ================================ T O P ===================================== 01 FIND ALL CAI-DETAIL-TBL ROWS 02 WITH SHIP-QTY GT 0 03 .. =========================== B O T T O M ================================== ------------------------------------------------------------------------------- <PF1> HELP <PF2> RETURN <PF3> DISPLAY COLUMNS <PF4> DISPLAY KEYS <PF5> DISPLAY ALL <PF6> LIST TABLES <PF7> BACKWARD <PF8> FORWARD <PF9> TEMPLATE <PF10> VALIDATE <PF11> RIGHT/LEFT <PF12> PROCESS MODE
|
Copyright © 2014 CA.
All rights reserved.
|
|