Provides a summary of totals for one or more numeric fields in
the current collection. The summary is sorted according to the
values in one or more fields of the current collection. The
summary includes subtotals for control groups. The summary can
be written to a file or an output device.
Format
[ {file-spec } ]
SUM print-list BY sort-list [ ON {*.prompt } ]
[ { } ]
1 – Arguments
print-list
Is a list of one or more numeric fields, other value expressions,
and modifiers. The print list has the following format:
{value-expression [ {modifier} [...] ] } [,...]
The section on the PRINT statement describes the value
expressions and modifiers you can use in a print list.
sort-list
Is a list of one or more sort keys that determine the order in
which DEC DATATRIEVE presents the summary totals. An item in the
sort list consists of the name of a field whose contents form
the basis for the sort, preceded or followed by a keyword that
determines the order DEC DATATRIEVE uses to sort the data.
To specify the sort order for each sort key, use one of the
following keywords:
ASC[ENDING]
DESC[ENDING]
INCREASING
DECREASING
If you specify more than one sort key, use a comma to separate
each sort key from the next.
file-spec
Is the file specification to which you want to write the output
of the statement.
A complete file specification has the following format:
node-spec::device:[directory]file-name.type;version
*.prompt-name
Is the prompting value expression that prompts you for the
file specification to which you want to write the output of the
statement.
2 – Example
The following example forms a collection of yachts and uses the
SUM statement to summarize the prices of yachts in the collection
and to display the number of yachts built by each builder. Edit
strings are used to format the values:
DTR> READY YACHTS; FIND FIRST 6 YACHTS
[6 records found]
DTR> SUM 1 ("NUMBER"/"OF YACHTS") USING 9,
CON> PRICE USING $$$$,$$$ BY BUILDER
NUMBER NUMBER
MANUFACTURER OF YACHTS PRICE OF YACHTS PRICE
ALBERG 1 $36,951
ALBIN 3 $64,000
AMERICAN 2 $28,790
6 $129,741
DTR>