ID: Q88889
The information in this article applies to:
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.
TOTAL TO <file> ON <key>
[<scope>]
[FIELDS <list>]
[FOR <expL>]
[WHILE <expL>]
The TOTAL command computes the total of the numeric fields of records in the currently selected database that match the <key> expression and places the total into the corresponding fields of records in a second database.
The current database must be sorted on the <key> expression or have an index enabled on the <key> expression. If the output <file> 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.
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:
Last Reviewed: April 17, 1995