Derived Tables Rules and Behavior

The rules and behavior of a derived table include:

  To build a query that uses a derived table:

  1. Build the query which will use the “derived table” and process the query.

  2. Insert a new query by choosing New Query on the Insert menu.

    A derivable query can be built for a relational database.

  3. Build the “Derived Table” query by clicking anywhere in the Catalog pane and selecting Derivable Queries on the shortcut menu.

    The “Derivable Queries” option is not displayed if no query sections can be used in the current query.

    (The Table Catalog below shows the Derivable Queries tree expanded and the Tables tree contracted. Local Results only are displayed when a user has requested them from the speed menu.)

    The only queries that are displayed in this list are those that:

    • have the same connection information as the current Query section

    • have at least one item on the Request line

    • do not use local joins

    • do not also contain derived table topics

    The topic name, when a derived table is added to the work area, is the same as the Query section name, and the column names are the same as the names of the items on the Request line in the Query section being added with the exception of any (data) function component. In cases where the function is displayed on the Request line, the resulting topic item name would be the same as the name that is displayed in Results after processing the query. The following diagram illustrates how the Request line for Query2 are displayed as a topic in another Query section.

  4. Create a manual join by dragging an item from at least one topic to another, including to/from the added derivable query sections.

    Once the derived table becomes a topic, items from it can be added to the Request, Filter, or Sort lines of the containing query. It can be referenced in computed item dialogs, and can be used in custom GROUP BY logic.

    If you use the Show Values feature when setting a filter on an item in the “derived table”, the SQL that would be used is the same as if you set a filter on the same column in the source Query section.

  5. Process the query using the derived table.

    You can process the query by way of “Process” command when viewing the query section (or one of its dependent sections) or by checking it in the Process Custom dialog.

    The “Process All” command processes the query containing the derived table. It also processes the query section from which the derived table is derived, unless it explicitly removed using the Query Processing Order dialog (which is recommended to avoid duplication of processing at the database.)

    Additions to the Request line of the source Query are reflected in the topic item list of the referencing Query section the next time it is displayed.

    Once a Query section has been added to another Query or Data Model works area, changes to the source query section will check for dependencies and warn you of any discrepancies that might occur. For example, you might receive a warning if an item was removed from the source query’s Request line which is used someplace else (Request, Filter, Sort, etc.) in a Query that is deriving a table from the source query.