Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Ravi Taxali
  Where is Ravi Taxali?
 Markham
 Canada
 Ravi Taxali
 To: ven chin
  Where is ven chin?
 
 Singapore
 ven chin
 Tags
Subject: RE: Decimal place in cursor rounded up
Thread ID: 233720 Message ID: 233752 # Views: 24 # Ratings: 0
Version: Visual FoxPro 8 Category: General VFP Topics
Date: Monday, July 06, 2009 3:56:19 PM         
   


> > Dear all,
> >
> > I am having problem in the Select SQL into cursor.
> >
> > I have the below 2 statement.
> >
> > SELECT InvID, custname, chrgccy, ;
> > IIF(ddbcr = '+', IIF(chrgccy = 'USD', sum(usdamt), sum(localamt)), 0.00) as PosTotalAmt,;
> > IIF(ddbcr = '-', IIF(chrgccy = 'USD', sum(usdamt), sum(localamt)), 0.00) as NegTotalAmt, hdbcr;
> > FROM GetInvD;
> > GROUP BY InvID, custname, chrgccy, ddbcr;
> > INTO CURSOR TempGetInvH READWRITE
> >
> > 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
> >
> > Can anybody help me on this? I tried many ways which recommended in here, unfortunately, the issue is still yet to resolved.
> >
> > Thanks inadvance.
> >
> > Regards,
> > Ven

Hi Ven,

I tried the following code to simulate the last part of your post:

CREATE CURSOR TempGetInvH (InvID C(10), custname C(40), PosTotalAmt N(9,2), NegTotalAmt N(9,2))
INSERT INTO TempGetInvH VALUES ("123456", "companyA", 374.42, 0.00)
INSERT INTO TempGetInvH VALUES ("123456", "companyA", 374.42, 0.00)

SELECT InvID, custname,  sum(PosTotalAmt) as PosTotalAmt, sum(NegTotalAmt) as NegTotalAmt;
 	FROM TempGetInvH;
 	GROUP BY InvID, custname;
 	INTO CURSOR GetInvH READWRITE
 


However, I get the correct result (748.84) in the GetInvH cursor. May be there are additional records in TempGetInvH which make the total equal to 749.00, SELECT records for CustID = '123456' and verify the data being grouped.

- Ravi Taxali
Visual FoxPro Made Simple -- An excellent book for beginners as well as experienced programmers



COMPLETE THREAD
Decimal place in cursor rounded up Posted by ven chin @ 7/6/2009 10:02:04 AM
RE: Decimal place in cursor rounded up Posted by Frank Cazabon @ 7/6/2009 3:48:37 PM
RE: Decimal place in cursor rounded up Posted by Ravi Taxali @ 7/6/2009 3:56:19 PM
RE: Decimal place in cursor rounded up Posted by Yuri Rubinov @ 7/6/2009 4:11:16 PM
RE: Decimal place in cursor rounded up Posted by Anders Altberg @ 7/6/2009 9:12:33 PM