Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Building a conditional sum.
Message
 
To
24/12/1998 07:39:31
Marcelo Codino
Mystic & Faith - Sistemas -
Buenos Aires, Argentina
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00170185
Message ID:
00170207
Views:
16
En casos como esos, you personalmente lo que hago de la siguente manera. Creo un procedure file. ejemplo: mylibrary.prg

En MyLibrary.prg tendrias PROCEDURES y FUNCTIONS:

**********************************
FUNCTION SumaMensual( m.lcDBF, m.lnMonth )
**********************************
LOCAL m.lcSQLWhere, m.lnReturnValue

m.lnReturnValue = 0
m.lcSQLWhere = "MONTH(tabledate) = " + TRANS( m.lnMonth )

SELECT ;
SUM(IIF(cond,option1,option2)) AS n_amount ;
FROM m.lcDBF ;
WHERE &lcSQLWhere.
INTO ARRAY aResults

IF _TALLY > 0
m.lnReturnValue = aResults[1]
ENDIF

RETURN( m.lnReturnValue )

En el reporte. La expression seria for ejemplo:

SumaMensual( "c:\mytable.dbf", 12 ) && pasa la tabla y el mes

Al llamar to reporte, lo haces asi:

SET PROCEDURE TO MyLibrary
REPORT xyz TO PRINT NOCONSOLE
SET PROCEDURE TO

Dejame saber si esto no te es muy claro.
Juan L. Romero
gcandela@javanet.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform