> > SELECT InvID, custname, chrgccy, sum(PosTotalAmt) as PosTotalAmt, sum(NegTotalAmt) as NegTotalAmt;
> > FROM TempGetInvH;
> > GROUP BY InvID, custname, hdbcr;
> > INTO CURSOR GetInvH READWRITE
> >
> > Assume now in my TempGetInvH cursor, my data as below:
> > InvID Company PosTotalAmt NegTotalAmt
> >
> > 123456 companyA 374.42 0.00
> > 123456 companyA 374.42 0.00
> >
> > But, when it comes to cursor GetInvH, which i want to sum up my PosTotalAmt & NegTotalAmt, the data will becomes as below:
> > 123456 companyA 749.00 12.00
> >
> > The correct total should be
> > 374.42 + 374.42 = 748.84 instead of 749.00 for PosTotalAmt
Hi Ven,
I treied the following code:
CREATE CURSOR TempGetInvH;
(InvID c(6), custname c(10), PosTotalAmt n(10,2))
INSERT INTO tempgetinvh (invid, custname, postotalamt) VALUES ("123456", "companyA", 374.42)
INSERT INTO tempgetinvh (invid, custname, postotalamt) VALUES ("123456", "companyA", 374.42)
SELECT InvID, custname, sum(PosTotalAmt) as PosTotalAmt;
FROM TempGetInvH;
GROUP BY InvID, custname;
INTO CURSOR GetInvH READWRITE
BROWSE
and got the expected 748.84. Even though this is in VFP9 SP1, I am certain the same code should work in VFP 8
I noticed that your query included "chrgccy" and grouped on "hdbcr", technically you should include chrgccy in your group by clause as well, but I'm not sure if that is what is causing your problem.
Can you give some sample code similar to what I did which illustrates your problem better?
Frank.
Frank Cazabon
Samaan Systems Ltd.
www.SamaanSystems.com/