A QBE query can present not only data already in a table, but also results that can be calculated using that data.
_S/12 is an example of an expression. It means the result of dividing SALARY by 12. You can form expressions by using symbols for operations:
Within expressions you can use column headings (RATE*HOURS), constants (RATE*1.07), and column functions (AVG.(_S)/2).
In the report, column names for calculated values are different depending on whether you are using SQL/DS or DB2. You may see, for example:
The examples in this book were created using SQL/DS. You see the term EXPRESSION in column headings for calculated values.
You can produce reports with columns that contain the values of expressions. To do so, put the expression in an unnamed column as in the following query.
To show the total earnings of employees in Department 20, include _S + _C in the unnamed column.
When you run this query:
Q.STAFF | ID | NAME | DEPT | SALARY | COMM | | --------+-------+--------+------+--------+------+-----------| | P. | P. | 20 | _S | _C | P._S + _C | |
QMF produces this report:
ID NAME EXPRESSION 1 ----- --------- ------------ 10 SANDERS - 20 PERNAL 18783.70 80 JAMES 13632.50 190 SNEIDER 14379.25
The value of SALARY+COMM for employee 10 is NULL, because the value of COMM is NULL, and the result of any calculation with NULL is NULL.
You can get a report for everybody in Department 38 and their monthly salaries.
When you run this query:
Q.STAFF | DEPT | NAME | SALARY | | --------+------+------+--------+---------| | P.38 | P. | _S | P._S/12 | |
QMF produces this report:
DEPT NAME EXPRESSION 1 ---- ---------- ------------------ 38 MARENGHI 1458.895833333 38 O'BRIEN 1500.500000000 38 QUIGLEY 1400.691666666 38 NAUGHTON 1079.562500000 38 ABRAHAMS 1000.812500000