Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Summing up data with null values
Message
 
To
01/05/2005 12:42:17
Randy Wessels
Screentek Business Solutions, Llc.
Phoenix, Arizona, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01010013
Message ID:
01010018
Views:
30
None of the SELECT statements you posted do a JOIN so no NULL values are being "generated". However, I notice that the cursors referenced in the FROM clause have names that start with "temp". Perhaps those are generated via SQL SELECT statements with a LEFT JOIN, thereby creating NULL values for certain child fields? Or perhaps there really is NULL data stored in your tables.

In short, if you want null values to evaluate to zero, check out the NVL() function.

--Brad


>IF (curcursor.CURRENT + tdcursor.thirtydays + sdcursor.sixtydays + npcursor.ninetyplus + custdetail.deposit) != 0
>
>The above line is used in a form that can contain null results. I can't see that I have changed anything, but if any of these are null, the line evaluates to zero. I would like it to be the total of the numbers in all of the cursors treating nulls as zero. Any ideas? The cursors are populated by these statements:
>
>SELECT SUM(totaldue-totalpaid) AS CURRENT FROM tempinvpostless30 INTO CURSOR curcursor WHERE ALLTRIM(custno) == ALLTRIM(scancust.custno)
>
>SELECT SUM(totaldue-totalpaid) AS thirtydays FROM tempinvpostthirty INTO CURSOR tdcursor WHERE ALLTRIM(custno) == ALLTRIM(scancust.custno)
>
>SELECT SUM(totaldue-totalpaid) AS sixtydays FROM tempinvpostsixty INTO CURSOR sdcursor WHERE ALLTRIM(custno) == ALLTRIM(scancust.custno)
>
>SELECT SUM(totaldue-totalpaid) AS ninetyplus FROM tempinvpostninety INTO CURSOR npcursor WHERE ALLTRIM(custno) == ALLTRIM(scancust.custno)
>
>The applicaiton at one point ran under VFP7 and was upgraded to VFP8 and recently VFP9. I do have a SET ENGINEBEHAVIOR 80 active. I am pretty sure that it worked under 9.0, so I am not sure what changed. Please help...
>
>Randy Wessels
Previous
Reply
Map
View

Click here to load this message in the networking platform