7 64 3 KEEP_MAX Example

LANSA Technical

7.64.3 KEEP_MAX Example

A sales file contains details of a company division (#DIVNAM) and of an entire year's sales in 4 quarters (#QTR01 -> #QTR04). Produce a report that summarizes the maximum and minimum values and the total yearly sales by division.

DEF_BREAK    NAME(#SUMMARY) FIELDS(#TOTAL #MAXIMUM #MINIMUM) TRIGGER_BY(#DIVNAM)
 
SELECT       FIELDS(#DIVNAM #QTR01 #QTR02 #QTR03 #QTR04) FROM_FILE(DIVSALES)
  KEEP_TOTAL OF_FIELD(#QTR01 #QTR02 #QTR03 #QTR04) IN_FIELD(#TOTAL) BY_FIELD(#DIVNAM)
  KEEP_MAX   OF_FIELD(#QTR01 #QTR02 #QTR03 #QTR04) IN_FIELD(#MAXIMUM) BY_FIELD(#DIVNAM)
  KEEP_MIN   OF_FIELD(#QTR01 #QTR02 #QTR03 #QTR04) IN_FIELD(#MINIMUM) BY_FIELD(#DIVNAM)
  PRINT      LINE(*BREAKS)
ENDSELECT
 
ENDPRINT