Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using the SUM function in VFP 8.0 SQL code
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00888074
Message ID:
00888078
Views:
52
>Why do I get an error message in VFP 8.0 in regard to the SUM function? The error message says that sum.prg does not exist.
>
>SELECT ;
> APTRXFIL.VOUCHER_NO, ;
> APTRXFIL.INV_AMT, ;
> SUM(APTRXDST.DST_AMT) AS DST_AMT ;
> FROM ;
> APTRXFIL, ;
> APTRXDST ;
> WHERE ;
> APTRXFIL.VOUCHER_NO = APTRXDST.VOUCHER_NO AND ;
> APTRXFIL.INV_AMT <> SUM(APTRXDST.DST_AMT) ;
> GROUP BY ;
> APTRXFIL.VOUCHER_NO, ;
> APTRXFIL.INV_AMT ;
> INTO CURSOR tmpAPTransactions

Because you can't use an aggregate function in a where clause.

You might be able to do it like this:
SELECT ;
  APTRXFIL.VOUCHER_NO, ;
  APTRXFIL.INV_AMT, ;
  SUM(APTRXDST.DST_AMT) AS DST_AMT ;
 FROM ;
  APTRXFIL, ;
  APTRXDST ;
 WHERE ;
  APTRXFIL.VOUCHER_NO = APTRXDST.VOUCHER_NO ;
 HAVING ;
  APTRXFIL.INV_AMT <> DST_AMT ;
 GROUP BY ;
  APTRXFIL.VOUCHER_NO, ;
  APTRXFIL.INV_AMT ;
 INTO CURSOR tmpAPTransactions
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform