Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Strange calculation
Message
 
À
05/11/2008 09:03:14
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01359766
Message ID:
01359830
Vues:
29
>Current Values in field
>
>24900
>70200
>71500
>=====
>166600
>
>
>Supposed variable named Balance is=157360
>
>
>I want to get following values to equilize balance value
>
>15660
>70200
>71500
>=====
>157360
CREATE CURSOR crsTest (Fld1 I, Fld2 I)
INSERT INTO crsTest VALUES(24900,0)
INSERT INTO crsTest VALUES(70200,0)
INSERT INTO crsTest VALUES(71500,0)

newBalance = 157360
SELECT SUM(Fld1) FROM crsTest INTO ARRAY laOldBalance
koef = newBalance/laOldBalance[1]
lcAllSum = 0
SCAN
   REPLACE Fld2 WITH ROUND(Fld1*koef,0)
   lcAllSum = lcAllSum + Fld2
   IF RECNO() == RECCOUNT()
      REPLACE Fld2 WITH Fld2 + newBalance - lcAllSum 
   ENDIF
ENDSCAN
BROWSE NORMAL
SELECT SUM(Fld1), SUM(Fld2) FROM crsTest
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform