Creates a table that stores totals for specified numeric fields of records grouped by common key values.


TOTAL ON <key field> TO <filename> [[TYPE] PARADOX | DBASE]
[FOR <condition 1>]
[WHILE <condition 2>]
[FIELDS <field list>]

<key field>

The name of the field on which the current table has been indexed or sorted.

TO <filename>

The table to create.


Specifies the type of table you want to create, if <filename> does not include an extension. This option overrides the current SET DBTYPE setting. The TYPE keyword is included for readability only; it has no effect on the operation of the command.

FOR <condition 1>
WHILE <condition 2>

The scope of the command. The default scope is ALL.

FIELDS <field list>

Specifies which numeric and float fields to total. If you don't include FIELDS, dBASE Plus totals all numeric and float fields.


Use TOTAL to total the value of numeric fields in a table and create a second table to store the results. The numeric fields in the table storing the results contain totals for all records that have the same key field in the original table.

The current table must be either indexed or sorted on the key field. All records with the same key field become a single record in the table storing the result totals. All numeric fields appearing in the fields list contain totals. All other fields contain data from the first record of the set of records with identical keys.

To limit the fields that are created in the new file, or to group on more than one key field, use SET FIELDS as shown in the example.

TOTAL is similar to SUM, except that SUM operates on an indexed or unindexed table, returning a sum for all records of each numeric field. SUM doesn't create another table, but stores the results to memory variables or an array.


No equivalent.