CREATE CURSOR aaa ( ax i NULL) INSERT INTO aaa values(NULL) INSERT INTO aaa values(1) INSERT INTO aaa values(2) INSERT INTO aaa values(3) INSERT INTO aaa values(4) && this have variant NULLs, and correctly don't fire a error SELECT COUNT(IIF(ax%1=0,CAST(NULL AS I),CAST(NULL AS C))) FROM aaa * bug: this fire a error because the first phase of the SELECT search a datatype * VFP engine solution: COUNT() uses a Logical nullable always SELECT COUNT(NULL) FROM aaa * Where this create a problem ? On conditional Count * The standard code for conditional count is : * NVL(SUM(IIF(condition,1,0)),0) * but this solution IS not the best solution * today i have found the correct solution : * COUNT(EVL(condition,NULL)) * but the null bug force to a useless casting * SELECT COUNT(CAST(EVL(condition,NULL) AS L)) FROM aaa SELECT COUNT(EVL(ax%1,NULL)) FROM aaa && the first record return a logical null CREATE CURSOR aaa ( ax i NULL) INSERT INTO aaa values(1) INSERT INTO aaa values(2) INSERT INTO aaa values(3) INSERT INTO aaa values(4) && the first record return a logical .f., then the literal null fire the error SELECT COUNT(EVL(ax%1,NULL)) FROM aaa SELECT COUNT(CAST(EVL(ax%1,NULL) AS L)) FROM aaaFabio