Previous Topic: Step 8: Sort Data for the ReportNext Topic: Step 10: Begin Defining the Report's Appearance


Step 9: Specify Sorting Priority and Control Breaks

DQHE0

 =>  --------------------------------------------------------------------------DQHE0  DATAQUERY:  ROW ORDERING                      QUERY NAME:    USER-SAMPLE  ------------------------------------------------------------------------------  If you chose more than 1 sort column, number them 1, 2, etc. to show their  sort priority from major to minor. Defaults are provided and can be modified.  Sort sequence, control breaks, and paging control may be selected  by placing any character in the corresponding fields.  -------------------------------------------------------------------------------  ORDER | TABLE NAME/                           |SORT SEQUENCE |CONTROL | NEW  NUMBER|  KEY OR COLUMN NAME                   |ASCEND/DESCEND| BREAK  | PAGE  -------------------------------------------------------------------------------        |CAI-DETAIL-TBL                         |              |        |   01   | CUST-ID                               |   X          |        |        |                                       |              |        |        |                                       |              |        |        |                                       |              |        |        |                                       |              |        |        |                                       |              |        |        |                                       |              |        |  - LAST PAGE -------------------------------------------------------------------  <PF1> HELP           <PF2> RETURN         <PF3> NOT USED   <PF4> CONTINUE  <PF5> EXTEND COLUMN  <PF6> DISPLAY QUERY  <PF7> BACKWARD   <PF8> FORWARD

Purpose

The ROW ORDERING panel appears when you select a column to be sorted. On it are listed the columns which you selected in the order in which they were listed on the previous panel. Their order on the ROW ORDERING panel indicates sorting priority from major to minor. You can change the priority. This panel also allows you to specify whether you want to sort from lowest to highest or highest to lowest value. Especially important, this panel lets you use the sort columns during execution to allow control breaks or start a new report page for each logical group created by sorting.

Concepts

These are the major concepts related to this panel:

Order
If the data in more than one column is to be sorted, order is important. CA Dataquery assigns a default number to each sort column you select. You can change it. The major sort is performed on the column to which 01 is assigned, the next sort on 02, and so on.

Ascending Sequence
From A to Z and from 0 to 9.

Descending Sequence
From highest to lowest -- 9 to 0 and from Z to A.

Control Break
A control break refers to a point in processing where CA Dataquery finds a different data value than one it has just read. If directed, CA Dataquery performs a specified function at the control break.

Query authors designate columns for control breaks to tell CA Dataquery to read the values in a sorted column and take a break in processing when it reads a different value. At a control break, CA Dataquery can perform other functions, calculating subtotals for the rows just processed. You still have to tell CA Dataquery which columns to perform the control break process on, but you do not do that using this panel.

Example

The following example shows how CA Dataquery sees the rows found by a query after sorting them by LASTNAME. Since the query author specified LASTNAME as a control-break column, CA Dataquery sees the rows containing identical values in that column as logical groups and takes a control break after each group. If subtotals were specified on another panel for the CONTRIBUTION column, CA Dataquery would total the CONTRIBUTION values for each group at the control break.

LASTNAME

FIRSTNAME

CLASS

CONTRIBUTIONS

Adams

James

A

45345.89

Adams

Arlene

C

98765.21

Adams

Robert

C

23456.90

>>>>>>>>>> Control Break <<<<<<<<<<

Burns

John

A

7897.32

Burns

Jeff

C

198.21

Burns

Alice

B

99321.42

>>>>>>>>>> Control Break <<<<<<<<<<

Crosby

Fred

A

278.13

Crosby

Mary

C

9978.13

>>>>>>>>>> Control Break <<<<<<<<<<

Use control breaks to organize the selected data, grouping it to provide more easily understood results. Control breaks also provide a way to summarize large volumes of data.

Note: For more information about control breaks, see the CA Dataquery Reference Guide.

New Page
You can have CA Dataquery start a new page or new screen every time there is a control break.

Panel Operation

On this panel, you use the Tab key to move the cursor from one column to another. You can type over numbers in the Order column, erase default Xs in the Ascending column, and tab to the columns in the Descending, Control Break, and New Page columns. When you are finished, you press <PF4> CONTINUE to display the next panel.

Completed Example

The following shows how the completed ROW ORDERING panel tells CA Dataquery to sort the report data by customer ID and to perform a control break each time it encounters data for a new customer.

 =>  --------------------------------------------------------------------------DQHE0  DATAQUERY:  ROW ORDERING                      QUERY NAME:    USER-SAMPLE  ------------------------------------------------------------------------------  If you chose more than 1 sort column, number them 1, 2, etc. to show their  sort priority from major to minor. Defaults are provided and can be modified.  Sort sequence, control breaks, and paging control may be selected  by placing any character in the corresponding fields.  -------------------------------------------------------------------------------  ORDER | TABLE NAME/                           |SORT SEQUENCE |CONTROL | NEW  NUMBER|  KEY OR COLUMN NAME                   |ASCEND/DESCEND| BREAK  | PAGE  -------------------------------------------------------------------------------        |CAI-DETAIL-TBL                         |              |        |   01   | CUST-ID                               |   X          |   X    |        |                                       |              |        |        |                                       |              |        |        |                                       |              |        |        |                                       |              |        |        |                                       |              |        |        |                                       |              |        |  - LAST PAGE -------------------------------------------------------------------  <PF1> HELP           <PF2> RETURN         <PF3> NOT USED   <PF4> CONTINUE  <PF5> EXTEND COLUMN  <PF6> DISPLAY QUERY  <PF7> BACKWARD   <PF8> FORWARD

This chart explains each entry/selection.

Field/Item

Sample Entry

Reason

Ascend

X

To order the customer IDs from lowest to highest.

Control Break

X

To produce subtotals of certain data for each customer.

Options

You could also tell CA Dataquery to start printing the data for each customer on a new page. If you were printing hard copies of your report and wanted to send each customer a record, that is what you would do.

To Go to the Next Step

Once the search and sort specifications are complete, the next panel specifies what to print in the report. <PF4> CONTINUE displays the next panel.

Following is a sample of how the panel looks so far.

=> --------------------------------------------------------------------------DQHN0 DATAQUERY: GUIDED QUERY DISPLAY QUERY NAME: _______________ ------------------------------------------------------------------------------- ================================ T O P ====================================== FIND ALL CAI-DETAIL-TBL WITH SHIP-QTY GT 0 SET SHIP-PRICE(13.2) = CAI-DETAIL-TBL SHIP-QTY * CAI-DETAIL-TBL UNIT-PRICE SORT CAI-DETAIL-TBL (CUST-ID) ============================== B O T T O M ================================== ------------------------------------------------------------------------------- <PF1> HELP <PF2> RETURN <PF3> NOT USED <PF4> CONTINUE <PF5> EXTEND COLUMN <PF6> DISPLAY QUERY <PF7> BACKWARD <PF8> FORWARD

So far, this query reads (FINDs) all CAI-DETAIL-TBL table rows in the search for data that have (WITH) a SHIP-QTY greater than 0. It also calculates (SETs) for each row the result of SHIP-QTY multiplied by UNIT-PRICE. Completing this step specifies sorting (SORTs) the rows found by the customer ID and to take a control break every time the customer ID changes (parentheses around the column name).