Analyzing query text

Let us analyze the generated query text.

  • Click OK and review the query generated by the query wizard (listing 13.1).

    Listing 13.1. Query text

    SELECT
        Services.Warehouse,
        Services.Technician,
        Services.Customer,
        Services.Ref AS Document
    FROM
        Document.Services AS Services
     
    ORDER BY
        Document
The query text begins with the query description (listing 13.2).

Listing 13.2. Query description

SELECT
    Services.Warehouse,
    Services.Technician,
    Services.Customer,
    Services.Ref AS Document
FROM
    Document.Services AS Services

A query description always begins with the SELECT keyword followed by the list of selection fields. This list describes the fields that are included in the query result. The list can contain the fields themselves as well as certain expressions calculated based on the field values.

The data sources (the source query tables whose contents are processed in the query) are specified after the FROM keyword. In this case the data source is the Document.Services object (referential) table.

Aliases of the source data are specified after the AS keyword. In this case the alias is Services. Thereafter, the query text can reference that data source using the alias (listing 13.3).

Listing 13.3. Description of selection fields

SELECT
    Services.Warehouse,
    Services.Technician,
    Services.Customer,
    Services.Ref AS Document
FROM
    Document.Services AS Services

Selection fields can also have aliases that you can use to address these fields in the query text. In this case the alias of the Ref field is Document.

After the query description section, the query continues with the result ordering section (listing 13.4).

Listing 13.4. Ordering query results

ORDER BY
    Document

The ORDER BY clause is intended for sorting query result rows. It is followed by the ordering expression, which is generally a list of fields or expressions with their output order options.

In this case the result is ordered by the Document field (which is actually the Services.Ref field). The result is sorted in ascending order (if sorting order is not specified explicitly, the ascending order is applied).

Now let us proceed to specifying data composition schema settings.

Next page: Settings

Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.