Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Summing a large table
Message
From
18/12/2000 04:04:55
 
 
To
17/12/2000 11:30:44
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00454501
Message ID:
00454596
Views:
32
Hello Zlatko

Using a Running Total as you describe is the standard solution to this problem, but as you suspect there is always the fear that the totals may get out of step with the actual amounts.

You could put maintenance code in the system that re-calculates all the running Totals every night which would minimise the risk.

VFP is so fast that with the proper indexes you may find that you can avoid having to use running totals altogether.



>Let's say there's a table FRUITS like this:
>
>Product Qty
>-----------------
>BANANA 3
>APPLE 1
>CHERRY 2
>BANANA 5
>BANANA 6
>APPLE 1
>BANANA 8
>BANANA -2
>...
>-----------------
>
>So, we need a sum for each product and it's done with:
>
>SELECT product, sum(qty) FROM FRUITS GROUP BY 1 INTO CURSOR STOCK
>
>
>It works fine, but suppose the table has a lot of records with lots of products (and not only one filed to sum) and the SELECT statement takes some time, which is not acceptable in a situation. It can be done with creating a new table STOCKS, which is updated every time the primary FRUITS changes some values. It's rather unfriendly and complicated to program that kind of solution.
>
>Is there some simple way to do it?
>
>
>Thank's, Zlatko.
Previous
Reply
Map
View

Click here to load this message in the networking platform