Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
SUM works with equal SORT keys. If you don't have equal SORT keys, the fields aren't summed. If you do have equal SORT keys, then you get a sum for each sort key.
In your first post, you did not have any equal SORT keys, so none of the records were summed. If you want a total of the field for all of the records, you can use these DFSORT statements:
In your second post, you used the same field for SORT and SUM - that's not allowed, and if it were, nothing would be summed because none of the keys (the sum fields) would be equal. If you used:
Code:
SORT FIELDS=(4,1,CH,A)
OPTION ZDPRINT
SUM FIELDS=(1,3,ZD)
that would give you a total. The sort key (1 blank) would be equal for every record, so the field would be summed. Note that I added ZDPRINT to ensure that the records are readable (F sign).