Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Summing Billed and Collected
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01512706
Message ID:
01512707
Views:
58
>I am supposing it is not possible to sum billed and collected amounts within the same SQL statement using separate date fields, one for billed date and the other for deposit date., or is it? This is what I have so far, but haven't pursued the separate dates ads I am not sure how that could be done, unless maybe I did a UNION with two separate SQL statements preceding the UNION.
>
>I need to do a WHERE condition on the date range for January 2010 on the DEPOS_DATE field, however, that might not be able to be combined with the current where condition below. It seems that separate statements are needed.
>
>SELECT "January 2010" AS Month_Year, GrpID, Emp_ID, SUM(bill_prem) as Month_Billed, ;
>		BnftName, SUM(Cash_Paid) AS Month_Collected ;
>	FROM tmp1 ;
>	WHERE BETWEEN(bill_date, CTOD("01/01/2010"), CTOD("01/31/2010"));
>	INTO CURSOR tmp2 ;
>	GROUP BY GrpID, Emp_ID, BnftName
If you want to use different dates in the sums, use an IIF() expression as what to sum, something like:
SUM(IIF(BETWEEN(bill_date, DATE(2010,1,1), DATE(2010,1,31)), bill_prem, 0)
I also changed your CTOD() to use DATE(), which is much safer.

Tamar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform