Hi!
I am trying to create a cursor for a report using SELECT and doing some calculations to print on the report. I can usually recall data as I need it but need some help on the calculations. I have made it work with the following code but I am sure some of you could show me a much better way. I would appreciate any suggestions to improve.
VFP 6.0. I am rewriting a project from DOS FOX. The code I am trying to duplicate is as follows.
* a loop that sums the pbad1,pbad2.... to pbad30 to pbad
pmade = pgood + pbad && pgood field from table
pctbad = 0.00
IF pmade > 0
pctbad = (pbad/pmade) * 100
ENDIF
lbsmde = pmade * purwght
lbsbad = pbad * purwght
variables created do not need to be stored.
Thanks for any help.
Judi
I am trying to create a cursor for a report using SELECT and doing some calculations to print on the report. I can usually recall data as I need it but need some help on the calculations. I have made it work with the following code but I am sure some of you could show me a much better way. I would appreciate any suggestions to improve.
Code:
SELECT orders.jobsnumb,orders.ordrnumb, orders.partnumb, orders.custno, ;
customer.bname, customer.custno,orders.pgood, orders.pgwip, ;
orders.purwght, ;
(pbad1+pbad2+pbad3+pbad4+pbad5+pbad6+pbad7+pbad8+pbad9+pbad10+;
pbad11+pbad12+pbad13+pbad14+pbad15+pbad16+pbad17+pbad17+pbad19+pbad20+;
pbad21+pbad22+pbad23+pbad24+pbad25+pbad26+pbad27+pbad27+pbad29+pbad30);
AS pbad ;
FROM company!orders LEFT OUTER JOIN company!customer ;
ON orders.custno = customer.custno ;
WHERE &lcSortBy >= THISFORM.txtBegin.VALUE AND ;
&lcSortBy <=THISFORM.txtEnd.VALUE ;
INTO CURSOR temp1 ;
ORDER BY &lcSortBy ;
GROUP BY &lcSortBy
SELECT *, ;
SUM(pgood+pbad) AS pmade ;
FROM temp1 ;
INTO CURSOR temp2 ;
ORDER BY &lcSortBy ;
GROUP BY &lcSortBy
SELECT *, ;
SUM(IIF(pmade > 0,((pbad/pmade)*100), 0000)) AS pctbad ;
FROM temp2 ;
INTO CURSOR temp3 ;
ORDER BY &lcSortBy ;
GROUP BY &lcSortBy
SELECT *, ;
SUM(pbad * purwght) AS lbsbad, ;
SUM(pmade *purwght) AS lbsmde ;
FROM temp3 ;
INTO CURSOR csrScrap ;
ORDER BY &lcSortBy ;
GROUP BY &lcSortBy
VFP 6.0. I am rewriting a project from DOS FOX. The code I am trying to duplicate is as follows.
* a loop that sums the pbad1,pbad2.... to pbad30 to pbad
pmade = pgood + pbad && pgood field from table
pctbad = 0.00
IF pmade > 0
pctbad = (pbad/pmade) * 100
ENDIF
lbsmde = pmade * purwght
lbsbad = pbad * purwght
variables created do not need to be stored.
Thanks for any help.
Judi