>Hi,
>
>If I select records that don't satisfy my criteria I get 0 for count(*), but NULL for sum(IIF(myCondition, 1,0))
>
>Is this a documented beahvior?
>
>Thanks.
Hi William,
I don't think this behavior is properly documented in Help. All I can find is
-------------------------------------------------------------------------------------------------------------
When you use aggregate functions, such as MAX( ), in the SQL SELECT command without a GROUP BY clause, and the system does not find any matching records, Visual FoxPro returns a result set with a single record and it sets _TALLY to 1. In versions before Visual FoxPro 9.0, the system does not return any records and it sets _TALLY to 0.
--------------------------------------------------------------------------------------------
It doesn't tell you that COUNT may return a number and the SUM would return NULL. So, I guess, you can find this by trial and error method.
If it's not broken, fix it until it is.
My Blog