Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid total running amount
Message
De
03/07/2008 12:45:10
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
02/07/2008 09:21:28
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
01328170
Message ID:
01328753
Vues:
10
>Stefan,
>
>that's a really neat way of doing it! Thanks.
>
>
>>>How do I run a running total in column amount of my grid?
>>
>>You can get a running-totals column by doing a self-join:
>>
>>
>>CREATE CURSOR temp (idField Int, amount Num(15,2))
>>INSERT INTO temp VALUES (1, 11.3)
>>INSERT INTO temp VALUES (2, 8.7)
>>INSERT INTO temp VALUES (3, 10)
>>
>>SELECT T1.idField, T1.amount, SUM(T2.amount) ;
>>    FROM temp T1 ;
>>        JOIN temp T2 ON T2.idField <= T1.idField ;
>>    GROUP BY 1, 2 ORDER BY 1
>>
Excellent! The simpler, the better. (um... now I see this goes to Stefan...)

I can see how this can go out of hand for multiple fields, because of the need for all the fields to be in the group-by clause. So as long as this can stay in a separate narrow cursor and then be joined to the rest, this can be fast and remain powerful.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform