Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Different behavior of COUNT(*) and SUM()
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01359217
Message ID:
01359378
Vues:
33
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform