Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL SELECT help needed
Message
De
21/10/2001 10:25:45
 
 
À
19/10/2001 09:13:19
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00570729
Message ID:
00571430
Vues:
26
Rui,
I see. In addition to Hilmar's suggestion to use SCAN, you could also call a UDF in your SELECT statement. Something like this:
PRIVATE lnCount, lnSum
lnCount = 1
lnSum   = 0

SELECT cod, name, deb, cre, RunningBalance(deb-cre) AS nBalance FROM Test

FUNCTION RunningBalance
LPARAMETER tnValue

*-- User Defined Function that allows calculating running totals.
*-- Adds tnValue to lnSum.
*-- Assumes that the following variables are inititalized before
*-- the SQL SELECT command:
*-- PRIVATE lnCount, lnSum
*-- lnCount = 1
*-- lnSum   = 0

IF lnCount > 1
	lnSum = lnSum + tnValue
ELSE
	*-- skip first call (called by SQL parser)
	lnSum = 00000000.00
ENDIF

lnCount = lnCount + 1

RETURN lnSum
See also Message #534436 for additional info about calling UDFs from SQL SELECT.

>I dont want the total of the group, but the accumulated balance of the SUM.
Daniel
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform