Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Different behavior of COUNT(*) and SUM()
Message
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01359217
Message ID:
01359378
Views:
34
This message has been marked as the solution to the initial question of the thread.
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform