Displaying Summary Lines Above the Data

How to:

The SET SUBTOTALS command controls whether summary lines are displayed above or below the detail lines in a report. The summary commands affected include SUBTOTAL, SUB-TOTAL, RECOMPUTE, SUMMARIZE, COMPUTE, RECAP, and COLUMN-TOTAL.


Top of page

x
Syntax: How to Control Placement of Summary Lines
SET SUBTOTALS = {ABOVE|BELOW}
ON TABLE SET SUBTOTALS {ABOVE|BELOW}

where:

ABOVE

Places summary lines above the detail lines and displays the sort field values on every detail line of the report output.

BELOW

Places summary lines below the detail lines. BELOW is the default value.



Example: Placing Subtotals Above the Data

The following request against the EMPLOYEE data source sums deduction amounts and gross salaries by department, deduction code, and last name. It then subtotals the deduction amounts and gross salaries for each department. The following request places the subtotals below the detail lines (the default).

TABLE FILE EMPLOYEE               
SUM DED_AMT GROSS                 
BY DEPARTMENT                     
BY DED_CODE                       
  BY LAST_NAME                    
WHERE BANK_ACCT NE 0              
WHERE DED_CODE EQ 'FICA' OR 'CITY'
  ON DEPARTMENT SUBTOTAL          
  ON TABLE SET SUBTOTALS BELOW    
  ON TABLE SET PAGE NOPAGE        
END

The output is:

DEPARTMENT  DED_CODE  LAST_NAME                DED_AMT            GROSS
----------  --------  ---------                -------            -----
MIS         CITY      BLACKWOOD                 $31.76        $9,075.00
                      CROSS                     $82.69       $22,013.77
                      JONES                     $14.01        $6,099.50
            FICA      BLACKWOOD              $2,223.37        $9,075.00
                      CROSS                  $5,788.01       $22,013.77
                      JONES                    $980.64        $6,099.50
                                                                       
*TOTAL DEPARTMENT MIS                        $9,120.47       $74,376.54
                                                                       
PRODUCTION  CITY      BANNING                    $7.42        $2,475.00
                      IRVING                    $60.24       $17,094.00
                      MCKNIGHT                  $18.26        $9,129.99
            FICA      BANNING                  $519.75        $2,475.00
                      IRVING                 $4,216.53       $17,094.00
                      MCKNIGHT               $1,278.21        $9,129.99
                                                                       
*TOTAL DEPARTMENT PRODUCTION                 $6,100.40       $57,397.98
                                                                       
                                                                       
TOTAL                                       $15,220.88      $131,774.52

The following is the same request, but with the subtotals placed above the detail lines.

TABLE FILE EMPLOYEE               
SUM DED_AMT GROSS                 
BY DEPARTMENT                     
BY DED_CODE                       
  BY LAST_NAME                    
WHERE BANK_ACCT NE 0              
WHERE DED_CODE EQ 'FICA' OR 'CITY'
  ON DEPARTMENT SUBTOTAL          
  ON TABLE SET SUBTOTALS ABOVE    
  ON TABLE SET PAGE NOPAGE        
END

On the output, the grand total line comes first, then the subtotal for the MIS department followed by the detail lines for the MIS department, followed by the subtotal for the PRODUCTION department and its detail lines. Note that all sort field values display on each line of the report output.

DEPARTMENT  DED_CODE  LAST_NAME                DED_AMT            GROSS
----------  --------  ---------                -------            -----
TOTAL                                       $15,220.88      $131,774.52
*TOTAL DEPARTMENT MIS                        $9,120.47       $74,376.54
                                                                       
MIS         CITY      BLACKWOOD                 $31.76        $9,075.00
MIS         CITY      CROSS                     $82.69       $22,013.77
MIS         CITY      JONES                     $14.01        $6,099.50
MIS         FICA      BLACKWOOD              $2,223.37        $9,075.00
MIS         FICA      CROSS                  $5,788.01       $22,013.77
MIS         FICA      JONES                    $980.64        $6,099.50
                                                                       
*TOTAL DEPARTMENT PRODUCTION                 $6,100.40       $57,397.98
                                                                       
PRODUCTION  CITY      BANNING                    $7.42        $2,475.00
PRODUCTION  CITY      IRVING                    $60.24       $17,094.00
PRODUCTION  CITY      MCKNIGHT                  $18.26        $9,129.99
PRODUCTION  FICA      BANNING                  $519.75        $2,475.00
PRODUCTION  FICA      IRVING                 $4,216.53       $17,094.00
PRODUCTION  FICA      MCKNIGHT               $1,278.21        $9,129.99

Information Builders