Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Running total in a grid
Message
From
26/05/2014 14:13:41
 
 
To
24/05/2014 19:34:32
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01600660
Message ID:
01600701
Views:
102
>Hi. How do I show a running total in a grid column (like in a bank statement)? If not, how would you do the same in a SQL statement? thanks, randy

Hi,

Does this code help you?
Create Cursor mySample (sampleID i Autoinc, Date T, Credit Y, Debit Y)

INSERT INTO mySample (date, credit, debit) VALUES ;
(Datetime() - (100-1)*86400, 800,0)

INSERT INTO mySample (date, credit, debit) VALUES ;
(Datetime() - (100-10)*86400, 0, 600)

INSERT INTO mySample (date, credit, debit) VALUES ;
(Datetime() - (100-2)*86400, 0, 150.00)

INSERT INTO mySample (date, credit, debit) VALUES ;
(Datetime() - (100-3)*86400, 1800,0)

INSERT INTO mySample (date, credit, debit) VALUES ;
(Datetime() - (100-4)*86400, 50,0)

INSERT INTO mySample (date, credit, debit) VALUES ;
(Datetime() - (100-5)*86400, 0, 800)

INSERT INTO mySample (date, credit, debit) VALUES ;
(Datetime() - (100-6)*86400, 0,300)

INSERT INTO mySample (date, credit, debit) VALUES ;
(Datetime() - (100-7)*86400, 0,250)

Select a.sampleID, a.Date,a.credit,a.debit,;
sum(Nvl(b.credit-b.debit,0)) as runTot ;
 from mySample a ;
 left join mySample b on a.date >= b.date ;
 group by 2,1,3,4 ;
 order by 2
 
 BROWSE normal
Regards,

Koen
Previous
Reply
Map
View

Click here to load this message in the networking platform