Using QMF

Creating a column using expressions

You can create a column for your report by adding, subtracting, multiplying, or dividing the values in two or more columns. Then, you can include the resulting value as a new column with the WHERE keyword.

For example, this statement creates a new column that is the total of each employee's salary and commission:

SELECT NAME, SALARY + COMM
  FROM Q.STAFF
  WHERE SALARY + COMM > 20000

QMF displays this report when you run the query:

+--------------------------------------------------------------------------------+
|   NAME       EXPRESSION 1                                                      |
|   ---------  ------------                                                      |
|   WILLIAMS   20094.15                                                          |
|   GRAHAM     21200.30                                                          |
+--------------------------------------------------------------------------------+

QMF names the calculated column as follows:

It names additional defined columns EXPRESSION 2, EXPRESSION 3 (or COL2, COL3, or 2, 3) and so on.

If you want to change the column headings, see Changing column headings.

After you define the new column, you can use it just as you would a column you select from a table.

For more information on using arithmetic expressions, see the QMF Reference, SC26-4716-05 .


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]