ORDER BY (sort selected records)
The ORDER BY statement relies upon the IBM Sort Facility to pass user data to a sort exit as the second parameter in the list. Other sort facilities can be used if they are compatible with the IBM Sort Facility (use standard sort exits E15 and E35).
The ORDER BY statement can be overridden with your own sort control statement, such as the following:
//SORTCNTL DD *
options - -
/*
options - -
/*
Syntax
ORDER BY v1 v2 v3 v4 [IN DESCENDING SEQUENCE]
Usage
- Only one ORDER BY statement is allowed per report set.
- Specify 1 to 4 variables with ORDER BY. They can be either user-defined or predefined variables.
- ORDER statement with more than 1 variable must specify the same fields, placed in the same order, with the USING statement right after the word USING
- IN DESCENDING SEQUENCE orders the data from high to low values. The default is ascending order.
Examples
SELECT TYPE 6E RECORDS FROM CMRDETL
USING T6ETRID -
T6ERESP -
T6ECPUR -
T6EFCWT -
T6ESHWM -
T6EPAGCT
ORDER BY T6ETRID
SUMMARY
REPORT
END
USING T6ETRID -
T6ERESP -
T6ECPUR -
T6EFCWT -
T6ESHWM -
T6EPAGCT
ORDER BY T6ETRID
SUMMARY
REPORT
END
SELECT TYPE 6E RECORDS FROM CMRDETL
USING T6ETRID -
T6ERESP -
T6ECPUR -
T6EFCWT -
T6ESHWM -
T6EPAGCT
ORDER BY T6ETRID T6ERESP
SUMMARY
REPORT
END
USING T6ETRID -
T6ERESP -
T6ECPUR -
T6EFCWT -
T6ESHWM -
T6EPAGCT
ORDER BY T6ETRID T6ERESP
SUMMARY
REPORT
END
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*