Using QMF

Using unnamed columns in an example table

In previous examples, the named columns in the example table adequately represented the report you wanted to create. But for more complex queries, you need to add new "unnamed" columns or use target tables (see Adding a target table).

To add an empty column to your query, put your cursor beside the column name to the left of where you want to add a column. Then, press the Enlarge function key. You can also blank out an unwanted column name to create a new (unnamed) column.

You can add a column of descriptive information to your report by putting a constant in an example table in an added (unnamed) column.

The following example lists the names and addresses of the people listed in the Q.APPLICANT table with 14 years of education, and identifies each with the character constant APPLICANT.

When you run this query:



Q.APPLICANT | NAME  | ADDRESS | EDLEVEL |              |
------------+-------+---------+---------+--------------|
            | P.AO. | P.      | 14      | P. APPLICANT |

QMF produces this report:

NAME        ADDRESS            EXPRESSION 1
----------  -----------------  ------------
CASALS      PALO ALTO,CA       APPLICANT
REID        ENDICOTT,NY        APPLICANT
RICHOWSKI   TUCSON,AZ          APPLICANT

You could also use a numeric constant. A constant can be up to 254 characters in length and, in addition to alphabetic and numeric characters, it can contain #, $, and @.

Use example elements to refer to the columns in an

example table that are the source of the data for the expression in an unnamed column. For example, this query uses _S to refer to the values in the SALARY column and _C to refer to the values in the COMM column.

When you run this query:



Q.STAFF | ID | DEPT |           | SALARY | COMM |
--------+----+------+-----------+--------+------|
        | P. |  20  | P._S + _C | _S     | _C   |

QMF produces this report:

     ID   EXPRESSION 1
-------   ------------
     10              -
     20       18783.70
     80       13632.80
    190       14379.25

By using _S and _C, you can then create an expression from the values in two columns and put the sum of the two into the report, via the unnamed column.

There is no restriction on the location of the unnamed column. Like other data columns, however, the unnamed column must be to the right of the table-name column.

Example 1:

List yearly, monthly, and weekly salaries.



Q.STAFF | ID | NAME | SALARY |       |       |
--------+----+------+--------+-------+-------|
P.      |    |      | _S     | _S/12 | _S/52 |

Example 2:

List the IDs, the commission, and the sum of the salary and commission. Show the percentage of total earnings the commission represents, and list in descending order (DO.) by the percentage.



Q.STAFF | ID | SALARY | COMM |           |                       |
--------+----+--------+------+-----------+-----------------------|
        | P. | _S     | P._C | P._S + _C | P.100*_C/(_S+_C) DO.  |


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