Microsoft KB Archive/88889

{| = TOTAL Command Sums Only One Key Field =
 * width="100%"|

ID: Q88889

The information in this article applies to:


 * Microsoft FoxBASE+ for MS-DOS, versions 1.21 and 2.1
 * Microsoft FoxPro for MS-DOS, versions 1.0, 1.01, 1.02, and 2.0

SUMMARY
In FoxBASE+ and FoxPro, the TOTAL command computes the total of only one key field. This field must be the first field in the index expression.

Syntax
TOTAL TO ON   [ ] [FIELDS ] [FOR ] [WHILE ]

MORE INFORMATION
The TOTAL command computes the total of the numeric fields of records in the currently selected database that match the expression and places the total into the corresponding fields of records in a second database.

The current database must be sorted on the expression or have an index enabled on the expression. If the output does not already exist, FoxBASE+ or FoxPro creates the file with a .DBF default extension.

By default, the TOTAL command totals all numeric fields unless the FIELDS clause is specified.

If the numeric fields in the database file that receives the totals are not wide enough to contain the totals, numeric overflow may occur. When overflow occurs, FoxBASE+ and FoxPro conserve the most- significant digits of the totals, as follows:

1. The number of decimal places in the numeric representation is

reduced and the resulting total is rounded. 2. If the rounded total does not fit and the total field is 7 digits wide or wider, scientific notation is used to represent the total. 3. If the field is not wide enough to accommodate scientific notation, asterisks replace the contents of the total field.

Example
USE Video INDEX Rating TOTAL TO V_stotal ON Rating FIELDS Rating, Num_sold * V_stotal was not predefined.

USE V_stotal LIST rating, num_sold Record#    RATING     NUM_SOLD 1    G          675 2    N/R       2205 3    PG       21244 4    R        14351 Additional reference words: FoxDos 1.00 1.01 1.02 1.21 2.00 2.10 KBCategory: kbusage kbprg KBSubcategory:
 * }