DB2 graphic  QMF Version 8

Creating SQL queries with Query wizards

The Simple and Advanced Query wizards guide you through the SQL query creation process.

When you use the Simple Query wizard to create a query, you perform the following tasks:

  1. Select a table and one or more of its columns.
  2. Optionally summarize records.
  3. Specify the query name and output options.

When you use the Advanced Query wizard to create a query, you perform the following tasks:

  1. Select a table and one or more of its columns.
  2. Optionally, select other tables and columns.
  3. Optionally, specify table relationships.
  4. Optionally, specify filter criteria.
  5. Optionally, summarize records.
  6. Specify the query name and output options.

Each of these tasks is described in more detail in the following sections. The text in the margin identifies to which wizard each tasks applies.

Selecting tables and columns

You select a table from and the columns that the query returns with both the Simple and the Advanced Query wizards.

Note: Remember that the tables, columns and functions you see in the list boxes in your query tools come from the workbook you select in the New Query dialog box. If you do not see the table you want, or if you wish to exclude tables from these lists, cancel the query wizard and begin your query again.

The following figure shows the Tables and Columns page of the Simple and Advanced Query wizards.

Specifying table relationships

With the Advanced Query wizard, you can include more than one table in your query. The Advanced Query wizard displays additional Table and Columns pages for as many additional tables as you choose. You can also specify the relationships between tables by creating joins between columns of the same data type.

You can add and edit table relationships on the Workbooks page of the World Manager (right-click the table and click Properties).

The following figure shows the Table Relationship page of the Advanced Query wizard.

To create a table relationship with the Advanced Query wizard:

  1. Click a field in the Field from 'table name' list.
  2. Click the Column button, select a column, and click OK.
  3. Optionally change the operator by clicking the Operator field and then the Function button.
  4. Click a field in the Related field list.
  5. Click the Column button, select a column, and click OK. The column name appears in the formula field.
  6. Click the Accept button.

Specifying filter criteria

You can define filter criteria with the Advanced Query wizard. You can perform computations on data and display the results by specifying an expression. An expression consists of a column name, a constant, a quoted string, a keyword, a query parameter, a function, or any combination of these items connected by operators.

The following figure shows the Define Filter page of the Advanced Query wizard.

To create an expression, select the elements using the formula buttons, or type the expression into the formula field. For more information on formulas, see Modifying properties using the Formula bar.

Defining aggregates

You can use the Simple and Advanced Query wizards to define aggregates that summarize the data returned by your query. Use the lists to specify the column and aggregate or type the expression in the Summary calculations field.

The following figure shows the Define Aggregates page of the Simple and Advanced Query wizards.

Defining the Output

You can name your query and define its output with the Simple and Advanced Query wizards. You can define query output in the following ways:

The following figure shows the Define Output page of the Simple and Advanced Query wizards.

After you click Finish, you can view the results of the query in the Datasheet view of the Query Editor.


Go to the previous page Go to the next page

Downloads | Library | Support | Support Policy | Terms of use | Feedback
Copyright IBM Corporation 1982,2004 Copyright IBM Corporation 1982, 2004
timestamp Last updated: March, 2004